2017-07-26 166 views
0

在模型我有以下範圍的關聯:滑軌:作用域相關聯,導致錯誤

customer.rb:38

has_many :payment_informations, class_name: 'Customer::PaymentInformation', dependent: :destroy, -> { order(position: :asc) } 

錯誤:

syntax error, unexpected '\n', expecting =>

-

我在這裏做錯了什麼?這個錯誤只發生在組建範圍時。

回答

1

嘗試

has_many :payment_informations, -> { order(position: :asc) }, class_name: 'Customer::PaymentInformation', dependent: :destroy 
+0

好......... :) – jonhue

1
has_many(name, scope = nil, options = {}, &extension) 

這是訂單的has_many預期。

+0

感謝您的解釋! – jonhue