ruby test.rb
class Order < ActiveRecord::Base
has_one :LineItem
end
class Item < ActiveRecord::Base
belongs_to :Order
end
order=Order.new
item=Item.new
order.name='o1'
order.item=item
has_one :LineItem
end
class Item < ActiveRecord::Base
belongs_to :Order
end
order=Order.new
item=Item.new
order.name='o1'
order.item=item
错误如下:
`method_missing': undefined method `item=' for #<Order:0xb7c4f5a8