我正在使用 Rails 3.2 和 Ruby 1.9.3
这是应用程序的外观:
模型
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
有人可以帮我找出问题吗?
提前致谢