I have an rails application which is quite big with many controllers (entities) I added a feature of enable and disabling of each entity which means that those which are disabled are not shown from view wise ..
Now my problem is
I have entities like A,B,C
A has B as foreign key
On A's controller there are many places where A will do a search of A's e开发者_开发知识库ntries on the whole.
How to filter the search of A's entries when B is disabled. My table structure is
A(id,category_type,category_id)
where category_id is the foreign key of B's id
Please give suggestions
In model A,
While you write the relation, you can specify like this ..
belongs_to :category, :conditions => {:enabled => true}
精彩评论