0
我有以下型號:的Rails 3.1無法與HAS_ONE創造:從鐵軌控制檯多態模型
class MenuItem < ActiveRecord::Base
has_one :price, :as => :pricable
accepts_nested_attributes_for :price
attr_accessible :price_attributes, :price
end
class Price < ActiveRecord::Base
belongs_to :pricable, :polymorphic => true
attr_accessible :price, :price_comment
end
我想在插入軌控制檯:
MenuItem.create({"name"=>"Julie's Mac & Cheese","price"=>{"price"=>14}})
但我得到這個錯誤:
ActiveRecord::AssociationTypeMismatch: Price(#70145189558680) expected, got Hash(#70145158648700)
我該如何強制它認爲這是一個價格?試圖用它作爲符號
thx?
thx - 作品很棒 – timpone