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