我有这个更新数据的动作:
def edit
@project = Project.find(params[:id])
if @project.team
@team = Team.find(@project.id)
else
@team = Team.new
end
end
形式:
= form_for @project do |f|
...
= f.fields_for @team do |t|
#if I use following: = f.fields_for :team do |t|, then the form inputs in this form are not displayed
...
end
end
楷模:
class Project < ActiveRecord::Base
has_one :team
accepts_nested_attributes_for :team
end
class Team < ActiveRecord::Base
belongs_to :project
end
当我尝试发送表单时,我收到以下错误消息
Team(#2501295380) expected, got ActiveSupport::HashWithIndifferentAccess(#2157764620)
我在 SO 上找到了类似的帖子,但没有人帮助我解决这个问题,这就是为什么我会非常感谢每一个建议。
非常感谢