0
我有一个默认范围模型:管理和unscoping默认范围
default_scope -> { where(is_active: true) }
我可以unscope的管理模型,让我可以看到在管理面板中的所有记录?
我有一个默认范围模型:管理和unscoping默认范围
default_scope -> { where(is_active: true) }
我可以unscope的管理模型,让我可以看到在管理面板中的所有记录?
您可以使用unscope方法来查找where
子句。以下是如何创建覆盖default_scope中where子句的新范围。
scope :including_inactive, ->{ unscope(where: :is_active) }
duplicate? http://stackoverflow.com/questions/1648971/rails-why-is-with-exclusive-scope-protected-any-good-practice-on-how-to-use-it – fanta
我不认为这是重复的的具体答案。 – mysmallidea