Hi, my webapp has registered users and it has articles, blog posts, gossips too.
For all these resources I've a polymorphic Comment model which is listed below.
id content commentable_id commentable_type user_id created_at updated_at
1 Frist comment 2 Article 1 ....
2 Second comment 3...
I have Fri Jun 26 23:05:00 -0400 2009
Which I'd like to convert into Eastern (US) time.
How can this be done with Ruby?
Thanks
...
I'm trying to test Rails' Javascript with Cucumber/celerity and factorygirl. The stack itself works, but database is going crazy.
I'm running mongrel on 3001 port (tried in both cucumber and test environments) and access it from cucumber via celerity.
One of my tests looks following:
create item
1 item exists
do smth with item
it w...
I'm just starting out with Ruby/Rails and am wondering what Rails developers use to provide reports and/or charts on Rails sites. In ASP.NET I use the tools from DevExpress but I don't know enough about the Rails ecosystem to know what is available. Any insight would be appreciated.
...
I have this method call I have to use...
financial_document.assets.length
But financial_document.assets could be nil.
I could use...
financial_document.assets.nil? ? '0' : financial_document.assets.length
Is there a less repetitive way to do that?
...
I think that acts_as_rateable seems to be quite obsolete and doesn't support AJAX.
I'm looking for a simple "5 star" rating system: is there any plugin or tutorial that can help?
...
I have a FinancialDocument#document_type model attribute. I'd like to let the user select the document type from an HTML select menu populated by an Array of Strings...
doctypes = [ 'Invoice', 'Packing slip', 'Other' ]
For each option, the displayed label and returned value would be identical.
I looked at the select and collection_se...
I've lived in the C++ world for years, and I'm just starting out with Ruby. I have a class that I would like to make a thread. In Ruby is it wrong to derive a class from Thread? The examples I see use the concept below.
Thread.new { <some block> }
Would it be wrong to do this?
class MyThread < Thread
def initialize
end
def ...
Ok, I've just spent the 4 hours trying to figure this one out without success. I've tried all the usual suspects and googled every combination of ruby 1.9.1, load path, gems, mac os x,freebsd,prawn and other stuff. The bottom line is this:
When I compile ruby1.9.1-p129 from sources on mac os x 10.5, the default load path ($:) I get is...
I want to do a logfile parser using ruby, this parser should parse the log file while it grows. It should parse line by line until the end and then wait (somehow?) for more lines to come, so my question is how to best handle it growing?
edit:
Would prefer a portable way of doing this, even though my logfile is on Windows (for the moment...
I'm going to be implementing a Web app using Rails with MySQL running on a small CentOS VPS. (Small server, limited user base to start out.) It's going to store a lot of text, sort of like a blog. I'd like to offer strong search options -- parens, AND, OR, exact phrase.
The other piece of it is that the data is private, so using Google ...
I'm new to rails so I apologize for my ignorance.
I'm setting a constant in a class outside of a method:
PARAM = { #... => ...
'field' => escape('somethingwith/slashes')
}
and get a NoMethodError: undefined method 'escape'
I tried Rack::Utils::escape and Rack::Utils.escape instead, but both don't work.
Thanks in advance....
The code
require 'yaml'
puts YAML.load("
is_something:
values: ['yes', 'no']
").to_yaml
produces
---
is_something:
values:
- "yes"
- "no"
While this is a correct yaml, it just looks ugly when you have a hash of arrays. Is there a way for me to get to_yaml to produce the inline array version of the yaml?
An options has...
Hi,
I have an issue with Ruby on Rails.
I have several model classes that inherit from the same class in order to have some generic behaviour.
The parent class is called CachedElement.
One of the child is called Outcome.
I want an other model, called Flow to belong to any child of CachedElement.
Hence Flow has a polymorphic attributes...
I'm writing some Rails code for a partial view, and I want it to only show a comment field if somebody is already logged onto a site here.
If the page is viewed by someone who isn't a member of the site yet, the shared/comment_not_logged_in fragment should be passed in.
However, I'm totally stumped as to why I can't run the same check ...
Hello,
What is the best place to go for free Ruby on Rails web hosting? I'm starting my project and I don't need a really good package for hosting, but if my project begins to grow then I'll pay for the best! Thanks.
...
In a Rails application I have a Test::Unit functional test that's failing, but the output on the console isn't telling me much.
How can I view the request, the response, the flash, the session, the variables set, and so on?
Is there something like...
rake test specific_test_file --verbose
...
I have a model like this...
Receipt
-------
amount:int # => An amount of money stored as cents.
But in the view I have these fields...
amount_dollars
amount_cents
So mass assignment won't work there.
What is the standard way to deal with this situation? Where do you put the code that converts the incoming values into an amount of...
Hi,
I have a table "users" with a column "date_of_birth" (DATE format with day, month, year).
In frontend I need to list 5 upcoming birthdays.
Spent ages trying to work out the logic.. also browsed every possible article in Google with no luck..
Any suggestions how to do this in RoR?
Thanks!
...
What's the best practice way for keeping track of who did what in a mid-sized Rails app? Intercepting all database read/writes and storing that in another table?
...