2
我有一个模型:如何将现有的named_scope添加到匿名作用域?
class Shirt < ActiveRecord::Base
named_scope :red, :conditions => { :color => 'red' }
named_scope :blue, :conditions => { :color => 'blue' }
named_scope :xl, :conditions => { :size => 'xl' }
end
我忘了,如何轻松命名范围添加到现有的匿名范围:
scope = Shirt.scoped({})
#and how to add ie. :red to scope?
您发布了,如何创建名称范围,但我想知道如何将现有范围添加到匿名范围。 – 2010-09-17 11:37:17
对不起 - 误解了。你的意思是:Shirt.scoped({})。red.xl – Codebeef 2010-09-17 13:18:14