Ruby on Rails: Devise gem, adding a "name" to a User model -
so have original version of devise, user authenticated through email address. however, want add option user enter name, of course doesn't matter if it's not unique, it's displaying purposes; how customize devise form? have :name attribute in user model already, here form looks like:
<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) |f| %> # field not working <div class="field"> <%= f.text_field :name, autofocus: true, placeholder: "what nickname?" %> </div> <div class="field"> <%= f.email_field :email, placeholder: "enter email address" %> </div> <div class="field"> <%= f.password_field :password, autocomplete: "off", placeholder: "enter password" %> </div> <div class="field"> <%= f.password_field :password_confirmation, autocomplete: "off", placeholder: "confirm password" %> </div> <div class="actions"> <%= f.submit "sign up" %> </div> <% end %>
where going wrong? when user signs name shows blank , not registered database...
i think problem related strong params. add applicationcontroller
.
class applicationcontroller < actioncontroller::base before_action :configure_permitted_parameters, if: :devise_controller? protected def configure_permitted_parameters devise_parameter_sanitizer.for(:sign_up) << :user end end
source: https://github.com/plataformatec/devise#strong-parameters
Comments
Post a Comment