Forum: Ruby on Rails Association Extensions and Conditions

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
34791e1d8c4def65f9b93294638a7e04?d=identicon&s=25 Joerg Diekmann (joergd)
on 2007-02-19 10:37
Hey,

I'm wondering whether the following 'should' work, but I'm just not
getting it right.


I have the following association on my model:

has_many :things do
  def cool
    find(:all, :conditions => { :cool => true })
  end
end


Now, I want to be able to do the following:

Suitcase.things.find(:all, :conditions => { :date => Date.today }).cool

I get an error that Array does not have a 'cool' method.


Any ideas?


Thanks
Joerg
34791e1d8c4def65f9b93294638a7e04?d=identicon&s=25 Joerg Diekmann (joergd)
on 2007-02-19 10:38
I forgot to add that


Suitcase.things.cool


works though. Just not if I combine it with an additional find.
This topic is locked and can not be replied to.