Forum: Ruby on Rails How does :condtions of belongs_to/has_many work?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
cool_screen_name90001 (Guest)
on 2005-11-24 03:39
(Received via mailing list)
If I put this in item.rb:

belongs_to :category, :conditions=>'site_id=1'

It doesn't appear to limit the categories to only those with site_id=1
(at least not with
form('item') in a view). I also tried putting this in category.rb:

has_many :items, :conditions=>'site_id=1'

And that doesn't change anything. I even put non-existant field names in
the conditions clauses
and it doesn't even cause an error. I also tried this in category.rb:

has_many :items, {:finder_sql=>'select * from categories where

and that didn't limit the categories either. belongs_to doesn't have a
finder_sql option. Am I
missing something?


Yahoo! Music Unlimited
Access over 1 million songs. Try it free.
This topic is locked and can not be replied to.