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

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.
81194a50c0f9bd95d7832a77fdf371bd?d=identicon&s=25 cool_screen_name90001 (Guest)
on 2005-11-24 02: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
site_id=1'}

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

thanks
csn



__________________________________
Yahoo! Music Unlimited
Access over 1 million songs. Try it free.
http://music.yahoo.com/unlimited/
This topic is locked and can not be replied to.