我有
class Foo < ActiveRecord::Base
named_scope :a, lambda { |a| :conditions => { :a => a } }
named_scope :b, lambda { |b| :conditions => { :b => b } }
end
我想要
class Foo < ActiveRecord::Base
named_scope :ab, lambda { |a,b| :conditions => { :a => a, :b => b } }
end
但我更喜欢以干燥的方式来做。我可以通过使用获得相同的效果
Foo.a(something).b(something_else)
但它不是特别可爱。