How would I write methods last and first in class Day? Day contains a field, date, and I want last to return the Day record in the table that has the greatest date and first to return the record that has the smallest date. How do I write the find? Sam -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
def last_date find :first, :order => "date DESC" end def first_date find :first, :order => "date ASC" end Usage: @first_day = Day.first_date @last_day = Day.last_date ...i guess something like this, but no guaranties :D --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Possibly Parallel Threads
- [LLVMdev] is the SmallVector implementation standard c++?
- Find last row (observation) for each combination of variables
- round Date object to 10 minutes intervals?
- Xen4CentOS6 project longevity
- PEAR Channel and Git Repository Mirror for PHP Markdown & Extra