0
我正在使用Devise gem構建RoR中的小頁面並卡住了。 當我想通過用戶模型的嵌套屬性保存配置文件時,出現錯誤,我無法克服它。在用戶模型中保存配置文件的嵌套屬性(Rails)
用戶模型
has_one :profile
accepts_nested_attributes_for :profile
剖面模型
belongs_to :user
編輯用戶視圖(在這裏我想補充的個人資料信息)
<% resource.build_profile %>
<%= form_for(resource, :as => resource_name,
:url => registration_path(resource_name),
:html => { :method => :put, :class => "custom" }) do |f| %>
(some fields for user)
<%= f.fields_for :profile, :child_index => resource.id,
:html => {:class => "custom"} do |profile| %>
<%= profile.label :name %>
<%= profile.text_field :name %>
<%= profile.label :surname %>
<%= profile.text_field :surname %>
<% end %>
<%= f.submit "Update my profile!" %>
<% end %>
錯誤在瀏覽器
Internal server error
錯誤在終端
!! Unexpected error while processing request: expected Array (got Rack::Utils::KeySpaceConstrainedParams) for param `profile_attributes'
感謝您的幫助在諮詢:)
編輯
那是愚蠢的錯誤..我有這個p在我的形式的代碼藝術:
<%= profile.select :gender, %w[Male Female], {}, { :index => nil }%>
我刪除{ :index => nil }
,現在的問題是走了:)
不幸的是沒有工作:(仍然是相同的錯誤... –