Rob Biedenharn wrote:

> class Household
>    def people_by_birthday
>      list = self.people.partition {|person| person.birthday.blank?}
>      list[1].sort_by(&:birthday) + list[0].sort_by(&:name)
>    end
> end
> 
> -Rob

This is the method I ended up with, almost.. I did

  def people_by_birthday
     list = self.people.partition {|person| person.birthday.blank?}
     list[1].sort_by(&:birthday)# + list[0].sort_by(&:name)
     return list[1]
  end

I had no use for the empty part of the partition, do it left.. Works 
perfectly.
Only problem now is that clearing empty dates trips the error message 
from failed validations.

Thanks a lot

Bob
-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to