开发者

FIlter search across application in rails when any of the entity is disabled

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}

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜