I added the column name to the users table which is based on the rails/devise gem. When I click on the admin tab that shows the list of users, I then click on the user name to bring up the edit page for that users profile. I get the following message.
Showing ~/rails/blog/app/views/users/_user.html.erb where line #8 raised:
undefined method `name_field' for #<ActionView::Helpers::FormBuilder:0x007fc716efd730>
Extracted source (around line #8):
6
7
8
9
10
11
<div class="field">
<%= f.label :name %><br />
<%= f.name_field :name, autofocus: true, autocomplete: "name" %>
</div>
<div class="field">
Trace of template inclusion: app/views/users/edit.html.erb
I tried to add:
def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up) { |u| u.permit(:name, :email, :password) }
devise_parameter_sanitizer.permit(:account_update) { |u| u.permit(:name, :email, :password, :current_password) }
devise_parameter_sanitizer.permit(:edit_profile) { |u| u.permit(:name, :email, :password, :current_password) }
to the application controller, but still get the same error.
How do I figure out where to make an modification to make rails understand that name_field is the field about the name ( yes, I looked at the migration and name is in the schema and has been migrated ).
How do I get it to accept that field as a defined field? I can't figure out the voodoo that creates that name_field, so I can't see where to make the change.
I used a scaffold to create the user admin pages. Why did it not create this correctly?
name_field
is not a valid form helper as Rails does not dynamically generate form helpers based on column names. Rail's form helpers, for the most part, are based off of valid HTML5 input types.
So when you see something like this in your devise form...
<%= f.email_field :email %>
f.email_field
is referencing the email HTML input type and :email
is referencing the attribute. The above helper generates the html...
<input type="email" name="user[email]">
So, your form field should use text_field
instead...
<div class="field">
<%= f.label :name %><br />
<%= f.text_field :name, autofocus: true, autocomplete: "name" %>
</div>