2
我的Rails的1碼一大堆使用此語法型號:軌道1至4升級:包括關鍵詞
...
has_many :widgets, :class_name => 'WidgetAssertion',
:include => [ :activity, :priority_assertion_type ]
...
軌道4,5拋出異常:
哪有我移植到Rails 4?
我的Rails的1碼一大堆使用此語法型號:軌道1至4升級:包括關鍵詞
...
has_many :widgets, :class_name => 'WidgetAssertion',
:include => [ :activity, :priority_assertion_type ]
...
軌道4,5拋出異常:
哪有我移植到Rails 4?
的has_many
的第二個參數是scope
:
你可以通過第二個參數
scope
作爲一個可調用(即PROC或lambda)來檢索一組特定的記錄或自定義生成的查詢,當您訪問相關收藏。
所以,在你的榜樣,你可以這樣做:
has_many :widgets, -> { includes(:activity, :priority_assertion_type) },
class_name: 'WidgetAssertion'
你沒那個使用的語法,有工作的希望任何「軌道1」代碼。你能提供準確的信息嗎? Ruby 1.9中引入了stabby lambda;如果您在Ruby 1.9上運行Rails 1代碼,則可能會遇到更大的問題。 –
我編輯它以反映實際的代碼。 – oystersauce8
什麼是例外? –