search for: jonrubyforum

Displaying 2 results from an estimated 2 matches for "jonrubyforum".

2006 Apr 03
1
Why no call to Model.new on find?
I created a model with some internal state derived from a combination of database and non-database data. Since I wanted to calculate these values once rather than every time they''re requested by the view, I calculated them in the initialize method and set some instance variables. However, I soon noticed that these values weren''t getting set when I retrieved data using the
2006 Apr 11
2
Getting distinct years from a date column the Rails way
I have an original_at column in my photos table. I''d like to get a list of distinct years that occur in this column, and some of the values are NULL. I see two ways of doing this. The SQLish way: photos = Photo.find :all, :select => ''distinct year(original_at)'' This is efficient in that it utilizes the database to do the filtering, and the code is not too ugly.