开发者

Exclude id in rails scope

How can I exclude some items in this scope:

s开发者_开发问答cope :within_category, ->(category) { joins(:category).where(:categories => { :id => category }) }

like this:

scope :within_category, ->(category, item_type) { joins(:category).where(:categories => { :id => category }, :id NOT IN item_type.id) }


Try this:

scope :within_category, ->(category, item_type) { joins(:category).where(:categories => { :id => category }).where(self.arel_table[:id].not_in(item_type.id) }
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜