Closed seanlinsley closed 8 years ago
Here's a stack trace for the error when being used with Formtastic: https://github.com/activeadmin/activeadmin/pull/4254#issuecomment-168422718
Sounds interesting, but I believe it's better to wait until we drop support for Rails 4.1/4.2 to use the new API, otherwise we will have to juggle with supporting multiple Rails APIs and Mongoid (which might not supply the same API for defining these attributes).
Is there a plan for when Rails 4 will be dropped, and alternatively when Rails 5 will be supported? Is there anything myself or others can do to help with that process?
@seanlinsley Devise 4 should keep compatibility with Rails 4.1, 4.2 and 5.0, but we currently don't have any plans for when to go Rails 5+ only.
Is the plan to support Rails 5 without dropping Rails 4 support, thus delaying usage of the new attributes API?
@seanlinsley yes.
Initially I described problem here https://github.com/activeadmin/activeadmin/issues/4280 and thought that it was Active Admin problem. Then I thought it was Formtastic problem and posted issue here https://github.com/justinfrench/formtastic/issues/1187, but @mikz prompted that it's possibly Devise 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'
Devise is added like so:
# Authentication
# Master branch is added for Rails 5 support
# https://github.com/plataformatec/devise/pull/3714
gem 'devise', github: 'plataformatec/devise', 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"
.
Is there any way to fix that except overriding these Active Admin forms and explicitly specifying type password
?
@arogachev can you set up a sample app with Devise + Rails 5 + Formtastic that replicates this issue so I can take a look? We might be able to come up with a different fix than using the new API.
@arogachev I couldn't replicate this issue in a fresh app (https://github.com/lucasmazza/devise-formtastic-rails-5) so I'm still now sure of what might be happening wrong here.
@lucasmazza Sorry, I didn't have enough time last days. I'll try either update gems or setup an app.
@lucasmazza I updated both devise
and formtastic
gems to the latest condition using bundle update
command (suffixed with gem name).
But then when I tried to start Puma (dev web server), I got this error:
/usr/local/rvm/gems/ruby-2.2.2@my_site/bundler/gems/activeadmin-599025964c95/lib/
active_admin/dependency.rb:79:in `match!': You provided devise 4.0.0.rc1 but we
need: ~> 3.2. (ActiveAdmin::DependencyError)
from /usr/local/rvm/gems/ruby-2.2.2@my_site/bundler/gems/activeadmin-5990
25964c95/lib/active_admin/dependency.rb:48:in `method_missing'
Here is the Gemfile
contents:
# Backend
gem 'activeadmin', github: 'activeadmin/activeadmin', branch: 'rails-5-rspec'
# Authentication
# Master branch is added for Rails 5 support
# https://github.com/plataformatec/devise/pull/3714
gem 'devise', github: 'plataformatec/devise', branch: 'master'
# FormBuilder DSL
gem 'formtastic', github: 'justinfrench/formtastic', branch: 'master'
Active Admin section in Gemfile.lock
looks like this:
GIT
remote: git://github.com/activeadmin/activeadmin.git
revision: 599025964c95d1caaad012c34bd5fb4074729152
branch: rails-5-rspec
specs:
activeadmin (1.0.0.pre2)
arbre (~> 1.0, >= 1.0.2)
bourbon
coffee-rails
formtastic (~> 3.1)
formtastic_i18n
inherited_resources (~> 1.6)
jquery-rails
jquery-ui-rails
kaminari (~> 0.15)
rails (>= 3.2, < 5.0)
ransack (~> 1.3)
sass-rails
Seems like rails-5-spec branch of Active Admin was not updated since the moment of my last update.
Is there any workaround to get it to work? Or it's Active Admin problem?
@arogachev looks like active admin has a virtual dependency on devise with ~> 3.2
, but now it should be something like >= 3.2
https://github.com/activeadmin/activeadmin/blob/rails-5-rspec/lib/active_admin/dependency.rb#L3-L5
The virtual dependency has been fixed in the latest PR commits: https://github.com/activeadmin/activeadmin/pull/4254 (diff link)
@seanlinsley Thanks for that! At least I will stay on rails-5-rspec
branch for now and update to the latest version.
i've followed this guide to make it work with rails5: https://rrott.com/blog/ror/rails-5-api-with-activeadmin-integration.html
In order for other gems (like Formtastic) to properly tell that the virtual password attribute is a string type, in Rails 5 Devise will need to use the new attributes API.
This is what currently happens:
But once Devise is hooked up with the new API,
type_for_attribute
would return:string
for the virtual password attribute.