0
我用Rails 3.2和Ruby 1.9.3Rails的HAS_ONE嵌套屬性,協會不匹配錯誤
下面是應用的樣子:
型號
Class Location
belongs_to :answer
attr_accessible :latitude, :longitude, :answer_id
end
Class Answer
attr_accessible :location
has_one :location
accepts_nested_attributes_for :location
end
控制器
def answer
@answer = Answer.new
@location = @answer.build_location
end
查看
<%= f.fields_for :location do |locator| %>
<%= locator.hidden_field :longitude, class:'longitude' %>
<%= locator.hidden_field :latitude, class:'latitude' %>
<% end %>
哈希發出(可見在日誌):
"answer"=>{"location"=>{"longitude"=>"2.3422566", "latitude"=>"48.8198344"}, "commit"=>"Send"}
錯誤:的ActiveRecord :: AssociationTypeMismatch
有人可以幫我找出問題?
由於提前