Nicolas Maloeuvre
Nicolas Maloeuvre

Reputation: 3169

Devise form : <input name="email"/> instead of name"user[email]"

autofill on Chrome on iOs is not working when there is <input name="user[email]"/>, only when there is <input name="email"/>

Is there a way to post { email: 'xx' }, instead of { user: { email: 'xx' } } with devise?

So I tried to generate Users::SessionsController < Devise::SessionsController in order to understand https://github.com/plataformatec/devise/blob/master/app/controllers/devise/sessions_controller.rb (def create) but I couldn't. I think I have to modify one or two lines on sessionscontroller#create but I don't understand warden.authenticate!

I think this is what warden call 'default_scope', I tried auth_option.merge({scope: :default}) but not working

maybe modifying devise_parameter_sanitizer, something like .merge({user:{email:params[:email], password:params[:password]}), i don't know

🤔

Upvotes: 1

Views: 384

Answers (1)

coorasse
coorasse

Reputation: 5528

You can user the autocomplete: "email" option in the field.

e.g. in SimpleForm:

<%=f.input :email, input_html: { autocomplete: 'email' } %>

https://developers.google.com/web/fundamentals/design-and-ui/input/forms/#recommended_input_name_and_autocomplete_attribute_values

Upvotes: 2

Related Questions