0
我有這2種型號:未定義的方法`shipping_info」爲#<的ActiveRecord ::關係
class Order < ActiveRecord::Base
has_one :shipping_info
end
class ShippingInfo < ActiveRecord::Base
belongs_to :order
end
@order = Order.new
@order.build_shipping_info fails with NoMethodError: undefined method `build_shipping_info' for #<ActiveRecord::Relation
任何想法,這是如何在軌道3做了什麼?
編輯:其實我也在控制檯得到這個:創建範圍:新。覆蓋現有的方法Order.new。
更新/已解決:其實我已經創建了一個新的作用域:錯誤新建,通過重命名作用域來解決問題。
請格式化您的問題。也許你只是拼錯了`@ order`到`@ oreder`? – tjeden 2010-11-26 11:53:46
您顯示的這段代碼是正確的。所以我想這不是你真正的代碼? – nathanvda 2010-11-26 12:27:37