Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Password field inputs are shown as regular inputs in Active Admin #1187

Closed
arogachev opened this issue Jan 22, 2016 · 9 comments
Closed

Password field inputs are shown as regular inputs in Active Admin #1187

arogachev opened this issue Jan 22, 2016 · 9 comments

Comments

@arogachev
Copy link

Initially I described problem here activeadmin/activeadmin#4280 and thought that it was Active Admin problem.

I'm using Rails 5.0.0.beta1, My Gemfile contents:

gem 'activeadmin', github: 'activeadmin/activeadmin', branch: 'rails-5-rspec'

I tried to update to latest commit of Formtastic on master branch, that didn't help:

gem 'formtastic', github: 'justinfrench/formtastic', branch: 'master'

For example, this line from this file:

f.input :password, label: t('active_admin.devise.password.title')

generates the following HTML:

<input type="text" name="user[password]" id="user_password" maxlength="72">

So there is no type="password".

@mikz
Copy link
Contributor

mikz commented Jan 22, 2016

@arogachev does this happen for all the fields or just devise ?
This might be devise problem. heartcombo/devise#3880

@arogachev
Copy link
Author

@mikz Thanks for fast reply. If i write something like this inside resource page:

form multipart: true do |f|
  f.inputs do
    f.input :password, as: :password
  end
end

input is shown correctly.

I can't fully understand magic behind:

f.input :password, label: t('active_admin.devise.password.title')

Here the type is not explicitly specified, so password is rendered by name password?

@mikz
Copy link
Contributor

mikz commented Jan 22, 2016

So the change that broke this is jtomaszewski@9e9fcd5
For devise inputs, the column has no type, so we just default to string. However, we could default the type to string and check for the method name. Will fix this asap.

@mikz
Copy link
Contributor

mikz commented Jan 22, 2016

@arogachev could you either provide sample project, or try to debug the code in question?

I see that it [should return :password](https://github.com/jtomaszewski/formtastic/blob/88f28a0bc2cdea61347b5f773ce058d68ce2fc4f/lib/formtastic/helpers/input_helper.rb#L296 even if the column type is nil) (devise case).

Also, I pushed an experimental branch enabling the new Attribute API #1188.

And last, but not least. Pushed example app https://github.com/mikz/rails-5-formtastic-example that works for me. User password and password_digest correctly show as password input.

@mikz
Copy link
Contributor

mikz commented Jan 24, 2016

@arogachev I can't reproduce this with rails 5. So I'd probably blame Devise for doing something bad.
I'm going to close this as can't reproduce. Feel free to create a PR on https://github.com/mikz/rails-5-formtastic-example that reproduces the issue.

@arogachev
Copy link
Author

@mikz So if attribute name is password and type is not explicitly specified, Forttastic guesses that it has password type, right?

@mikz
Copy link
Contributor

mikz commented Jan 25, 2016

@arogachev yes, it matches the method name for /password/ even when the type is unknown.

@arogachev
Copy link
Author

@mikz I just tested, in separate resource page this works fine:

form multipart: true do |f|
  f.inputs do
    f.input :password
  end
end

So turns out this is Devise problem, I left the comment here heartcombo/devise#3880.

@mikz
Copy link
Contributor

mikz commented Jan 28, 2016

@arogachev thanks ! Closing this then. Reopen it if something is needed from formtastic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants