ruby on rails, devise custom signup and login -
i trying devise working rails project. customizing views. got accept , authenticate name field , email password code:
in config , initializer devise file
config.authentication_keys = [:name, :email]
and in new session view
<div class="field"> <%= f.label :name %> <% if resource.errors.has_key?(:name) %> <em><%= resource.errors[:name] %></em> <% end %><br /> <%= f.text_field :name, autocomplete: "off" %> </div>
if remove authentication_key
name never saves name added key authentication_keys
, works
however, login don't want authenticate email , work name , password
and having problems in doing that
i checked sign_up
, works , creates new user data.
let me know if got ideas, thanks
if want use name login change authentication keys without email
config.authentication_keys = [:name]
additional code
if want include email when user sign_up
open application controller , add below code
class applicationcontroller < actioncontroller::base before_action :configure_permitted_parameters, if: :devise_controller? protected def configure_permitted_parameters devise_parameter_sanitizer.permit(:sign_up, keys: [:email]) end end
Comments
Post a Comment