with_exclusive_scope (ActiveRecord::Base) – APIdock
In Rails3 use "unscoped" instead
The with_exclusive_scope examples no longer work in Rails3 because with_exclusive_scope is now a protected method which can and should not be used in a controller. Use the new unscoped method instead:
ほー。
class Post < ActiveRecord::Base
default_scope :published => true
end
Post.all #=> SELECT * FROM posts WHERE published = true
Post.unscoped.all #=> SELECT * FROM posts
ほほー。
コメント
[…] default_scopeを全部外すにはunscopedだったのですが、特定の条件だけ外すにはどうしたらよいのか調べていたら、こちらにたどり着きました。 default_scopeのorderをキャンセルする – とある […]