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