named_scop
1 User.active do 2 User.count # => Not run 3 end 4 5 User.active.with_scopedo 6 User.count #=> Not scoped 7 end
そこで、昔ながらのwith_scope
これを使うと、以下のように期待通りに動きます。
1 User.active.with do 2 User.count #=> User.active.count 3 end
なかなか便利だと思うので、Rails本家にパッチを送っておきました。
posted by
genki
on Fri 1 Aug 2008
at 21:16