我正试图将表单字段添加到我的Devise用户注册视图中。这已经实现,验证在我提交表单时运行。但是,如果我遇到任何表单错误,输入数据不会按照原始表单重新填充表单字段,尽管我可以在添加到开发视图的小调试器中看到正确的值。
以下是我的观点:
<h2>Sign up</h2>
<% resource.build_profile %>
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>
<div><%= f.label :email %><br />
<%= f.email_field :email %></div>
<div><%= f.label :username %> <i>(this cannot be changed so choose wisely)</i><br />
<%= f.text_field :username %></div>
<div><%= f.label :password %><br />
<%= f.password_field :password %></div>
<div><%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation %></div>
<%= f.fields_for :profile do |profile_form| %>
<div><%= profile_form.label :full_name %><br />
<%= profile_form.text_field :full_name %></div>
<div><%= profile_form.label :birth_date %><br />
<%= profile_form.date_select :birth_date, start_year: Time.now.year, end_year: Time.now.year - 80, order: [:day, :month, :year], prompt: { day: Choose day , month: Choose month , year: Choose year } %></div>
<div><%= profile_form.label :gender %><br />
<%= profile_form.select :gender, { "Male" => 0 , "Female" => 1 } %></div>
<div><%= profile_form.label :postcode %><br />
<%= profile_form.text_field :postcode %></div>
<div><%= profile_form.label :description, "About you" %><br />
<%= profile_form.text_area :description %></div>
<% end %>
<div><%= f.submit "Sign up" %></div>
<% end %>
<%= render :partial => "devise/shared/links" %>
我没有控制器代码可以显示,因为它在Gem中使用了Devise代码。我做错了什么/没做什么?