從模型中獲取數據時出現錯誤,下面是我的場景創建了一個「ProductSearch」引擎,在ProductSearch內部我有控制器,模型,幫助器和視圖。未定義的方法all:{:conditions => {:retailer_id => [1,2]}}:Hash在rails引擎中
現在控制器的方法給出了一個錯誤,而下面執行的是控制器方法
def stores_in_mall
@stores ||= TenantRetailigenceRetailer.
for_property(@property).all(:include => :retailer, :order => 'retailers.name').
reject{ |s| s.retailer.nil? || s.retailer.suite.nil? }
end
下面的代碼是產品搜索型號
module ProductSearch
class TenantRetailigenceRetailer < ActiveRecord::Base
belongs_to :retailer
belongs_to :retailigence_retailer
attr_accessor :tenant_id, :retailigence_retailer_id
scope :for_property, lambda{ |property|
{ :conditions => { :retailer_id => property.retailers.map(&:id) } }
}
def name
retailer.name
end
end
end
您正在使用導軌4? – Thorin
只是更改範圍:for_property,lambda {| property | – Thorin
是的我正在使用rails 4 @Thorin – user3906755