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

Devise, Heroku and the Asset Pipeline #1339

Closed
bradleypriest opened this issue Sep 21, 2011 · 36 comments
Closed

Devise, Heroku and the Asset Pipeline #1339

bradleypriest opened this issue Sep 21, 2011 · 36 comments

Comments

@bradleypriest
Copy link

I'm not sure if this has been mentioned before, and I'm not sure where to even start fixing it.
When deploying a Rails 3.1 app to Heroku, it runs the asset compilation rake task during the deploy.
However in an app with devise in it this compilation fails because the devise_for route helper causes the rake task to need to talk to the database, which doesn't exist yet.

Is this something that can be changed on Devise's end?

Any thoughts?
Cheers,
Brad

@dodeja
Copy link

dodeja commented Sep 21, 2011

+1 Have the same issue. Using Heroku Postgres on production.

@josevalim
Copy link
Contributor

Hrm, Do you have the backtrace of the error you get when precompiling? Devise loads the models but it does not force any query in the database, so I would assume that this is more likely to be a Heroku issue. I believe there is a way to load models but tell them that there is no database connection.

@bradleypriest
Copy link
Author

The bug can be reproduced by adding a non-existent database to the database.yml and running the rake task.

It does seem to be a strange bug.
In one of the problematic apps here, removing the has_and_belongs_to_many from the User model is another way to fix it. The other app doesn't have a has_and_belongs_to_many in it though, will have a look at it tonight.

@bradleypriest
Copy link
Author

It looks like the latest 3.1-stable branch fixes the has_and_belongs_to_many app.
The other app error I fixed by either removing an ActiveRecordObserver from the application.rb or removing a with_state method supplied by the state_machine gem from the associated model.

It seems the devise_for method seems to be exposing underlying stuff out. Not sure if there's anything to be done?

@josevalim
Copy link
Contributor

devise_for needs to look into the models in order to create url helpers. There is not much I can do here. If Rails had a flag that specifically told me that assets were being compiled, I could use this flag to skip loading assets. Maybe Heroku could provide this flag?

@josevalim
Copy link
Contributor

/cc @hone

@hone
Copy link

hone commented Sep 22, 2011

@josevalim I tried pushing https://github.com/plataformatec/devise-only-model and it worked fine on the cedar stack.

Here's the output from what I did: https://gist.github.com/e18f98db74634df7aa2c

@josevalim
Copy link
Contributor

Potentially fixed the issue here:

f199557

You will need both devise and rails 3-1-stable branch in order to fix the issue over heroku. Thanks for everyone's help.

@dodeja
Copy link

dodeja commented Sep 22, 2011

Still having this issue with the latest rails and devise branch. If I remove devise_for scope, It can precompile assets without issue. That's not really an ideal option.

gem 'rails', '3.1.1.rc1', :git => 'git://github.com/rails/rails.git', :branch => "3-1-stable"
gem 'devise' :git => 'git://github.com/plataformatec/devise.git'

@bradleypriest
Copy link
Author

@dodeja, the fix won't work until Heroku updates their code to use the new variable on compilation ( if they do ), in the meantime, have a quick look to see if you can work out what is being exposed by the devise_for block. It will most likely be a method in your devise model. Personally, one project was being broken by a has_and_belongs_to_many and another by with_scope, you may be able to work around the problem. See here for instructions on how to reproduce the bug locally

@josevalim
Copy link
Contributor

The environment variable is being set by Rails in Rails 3-1-stable. That said, it should work on Heroku. However, if you can reproduce the error locally and provide a backtrace, that would help a lot.

@dodeja
Copy link

dodeja commented Sep 23, 2011

I changed the database to a non-existing database and here is the trace.

(master) : bundle exec rake assets:precompile --trace
(in /Users/akshayd/Code/Strobeo/picwing)
** Invoke assets:precompile (first_time)
** Execute assets:precompile
(in /Users/akshayd/Code/Strobeo/picwing)
rake aborted!
Unknown database 'picwing_new22'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/mysql2-0.3.7/lib/mysql2/client.rb:43:in `connect'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/mysql2-0.3.7/lib/mysql2/client.rb:43:in `initialize'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `new'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `mysql2_connection'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:304:in `new_connection'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:323:in `checkout_new_connection'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:265:in `block (2 levels) in checkout'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:261:in `loop'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:261:in `block in checkout'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:260:in `checkout'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:162:in `connection'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:409:in `retrieve_connection'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb:107:in `retrieve_connection'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb:89:in `connection'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/activerecord/lib/active_record/attribute_methods/primary_key.rb:41:in `get_primary_key'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/activerecord/lib/active_record/attribute_methods/primary_key.rb:25:in `reset_primary_key'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/activerecord/lib/active_record/attribute_methods/primary_key.rb:16:in `primary_key'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/activerecord/lib/active_record/base.rb:1958:in `attributes_protected_by_default'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/activemodel/lib/active_model/mass_assignment_security.rb:191:in `protected_attributes_configs'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/activemodel/lib/active_model/mass_assignment_security.rb:99:in `attr_protected'
/Users/akshayd/Code/Strobeo/picwing/app/models/user.rb:7:in `<class:User>'
/Users/akshayd/Code/Strobeo/picwing/app/models/user.rb:1:in `<top (required)>'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/activesupport/lib/active_support/dependencies.rb:240:in `require'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/activesupport/lib/active_support/dependencies.rb:240:in `block in require'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/activesupport/lib/active_support/dependencies.rb:225:in `load_dependency'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/activesupport/lib/active_support/dependencies.rb:240:in `require'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/activesupport/lib/active_support/dependencies.rb:348:in `require_or_load'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/activesupport/lib/active_support/dependencies.rb:489:in `load_missing_constant'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/activesupport/lib/active_support/dependencies.rb:181:in `block in const_missing'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/activesupport/lib/active_support/dependencies.rb:179:in `each'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/activesupport/lib/active_support/dependencies.rb:179:in `const_missing'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/activesupport/lib/active_support/inflector/methods.rb:124:in `block in constantize'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/activesupport/lib/active_support/inflector/methods.rb:123:in `each'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/activesupport/lib/active_support/inflector/methods.rb:123:in `constantize'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/activesupport/lib/active_support/dependencies.rb:528:in `block in initialize'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/activesupport/lib/active_support/dependencies.rb:550:in `yield'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/activesupport/lib/active_support/dependencies.rb:550:in `default'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/activesupport/lib/active_support/dependencies.rb:550:in `[]'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/activesupport/lib/active_support/dependencies.rb:595:in `constantize'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/devise-f19955705fe2/lib/devise.rb:259:in `get'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/devise-f19955705fe2/lib/devise/mapping.rb:103:in `to'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/devise-f19955705fe2/lib/devise/mapping.rb:98:in `modules'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/devise-f19955705fe2/lib/devise/mapping.rb:115:in `routes'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/devise-f19955705fe2/lib/devise/mapping.rb:84:in `initialize'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/devise-f19955705fe2/lib/devise.rb:289:in `new'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/devise-f19955705fe2/lib/devise.rb:289:in `add_mapping'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/devise-f19955705fe2/lib/devise/rails/routes.rb:190:in `block in devise_for'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/devise-f19955705fe2/lib/devise/rails/routes.rb:189:in `each'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/devise-f19955705fe2/lib/devise/rails/routes.rb:189:in `devise_for'
/Users/akshayd/Code/Strobeo/picwing/config/routes.rb:4:in `block in <top (required)>'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/actionpack/lib/action_dispatch/routing/route_set.rb:258:in `instance_exec'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/actionpack/lib/action_dispatch/routing/route_set.rb:258:in `eval_block'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/actionpack/lib/action_dispatch/routing/route_set.rb:235:in `draw'
/Users/akshayd/Code/Strobeo/picwing/config/routes.rb:3:in `<top (required)>'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/activesupport/lib/active_support/dependencies.rb:234:in `load'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/activesupport/lib/active_support/dependencies.rb:234:in `block in load'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/activesupport/lib/active_support/dependencies.rb:225:in `load_dependency'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/activesupport/lib/active_support/dependencies.rb:234:in `load'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/railties/lib/rails/application/routes_reloader.rb:29:in `block in load_paths'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/railties/lib/rails/application/routes_reloader.rb:29:in `each'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/railties/lib/rails/application/routes_reloader.rb:29:in `load_paths'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/railties/lib/rails/application/routes_reloader.rb:13:in `reload!'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/railties/lib/rails/application/routes_reloader.rb:7:in `block in initialize'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/activesupport/lib/active_support/file_update_checker.rb:32:in `call'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/activesupport/lib/active_support/file_update_checker.rb:32:in `execute_if_updated'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/railties/lib/rails/application/finisher.rb:63:in `block (2 levels) in <module:Finisher>'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/railties/lib/rails/application/finisher.rb:64:in `call'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/railties/lib/rails/application/finisher.rb:64:in `block in <module:Finisher>'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/railties/lib/rails/initializable.rb:25:in `instance_exec'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/railties/lib/rails/initializable.rb:25:in `run'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/railties/lib/rails/initializable.rb:50:in `block in run_initializers'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/railties/lib/rails/initializable.rb:49:in `each'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/railties/lib/rails/initializable.rb:49:in `run_initializers'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/railties/lib/rails/application.rb:97:in `initialize!'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/railties/lib/rails/railtie/configurable.rb:30:in `method_missing'
/Users/akshayd/Code/Strobeo/picwing/config/environment.rb:8:in `<top (required)>'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/activesupport/lib/active_support/dependencies.rb:240:in `require'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/activesupport/lib/active_support/dependencies.rb:240:in `block in require'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/activesupport/lib/active_support/dependencies.rb:223:in `block in load_dependency'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/activesupport/lib/active_support/dependencies.rb:640:in `new_constants_in'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/activesupport/lib/active_support/dependencies.rb:223:in `load_dependency'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/activesupport/lib/active_support/dependencies.rb:240:in `require'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/railties/lib/rails/application.rb:83:in `require_environment!'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/railties/lib/rails/application.rb:194:in `block (2 levels) in initialize_tasks'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/rake.rb:634:in `call'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/rake.rb:634:in `block in execute'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/rake.rb:629:in `each'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/rake.rb:629:in `execute'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/rake.rb:595:in `block in invoke_with_call_chain'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/rake.rb:588:in `invoke_with_call_chain'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/rake.rb:581:in `invoke'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/rails-9eb628ad653c/actionpack/lib/sprockets/assets.rake:14:in `block (2 levels) in <top (required)>'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/rake.rb:634:in `call'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/rake.rb:634:in `block in execute'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/rake.rb:629:in `each'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/rake.rb:629:in `execute'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/rake.rb:595:in `block in invoke_with_call_chain'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/rake.rb:588:in `invoke_with_call_chain'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/rake.rb:581:in `invoke'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/rake.rb:2041:in `invoke_task'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/rake.rb:2019:in `block (2 levels) in top_level'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/rake.rb:2019:in `each'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/rake.rb:2019:in `block in top_level'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/rake.rb:2058:in `standard_exception_handling'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/rake.rb:2013:in `top_level'
/Users/akshayd/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/rake.rb:1992:in `run'
/Users/akshayd/.rbenv/versions/1.9.2-p290/bin/rake:31:in `<main>'

@josevalim
Copy link
Contributor

It seems that Rails is loading the routes and not Devise. I am not sure if it is worth to change Rails to not load the routes. @hone, what do you think?

@josevalim josevalim reopened this Sep 23, 2011
@josevalim
Copy link
Contributor

Please try again with Rails 3-1-stable branch. I have pushed a potential fix to Rails.

@nas887
Copy link

nas887 commented Sep 24, 2011

Hi Jose, I'm having the same issue and have upgraded to 3-1. No luck.

@josevalim
Copy link
Contributor

If it does not work on Rails 3-1-stable branch, there is nothing much I can do. It is not a Devise issue, that said, I am closing this.

@nas887
Copy link

nas887 commented Sep 28, 2011

Thanks Jose, appreciate the help. Was able to figure it out after all.

@andruby
Copy link

andruby commented Oct 8, 2011

@nas887: how did you fix it?

@nas887
Copy link

nas887 commented Oct 9, 2011

Hey Andrew,

Can you be a bit more specific, having trouble referencing this one problem
I ran into.

-Neil

On Sat, Oct 8, 2011 at 1:12 PM, Andrew Fecheyr <
reply@reply.github.com>wrote:

@nas887: how did you fix it?

Reply to this email directly or view it on GitHub:
#1339 (comment)

@andruby
Copy link

andruby commented Oct 9, 2011

Hi Neil,

I had the same asset:precompile error. I fixed it by changing a scope in my devise user model to a lambda.

On 09 Oct 2011, at 19:06, Neil reply@reply.github.com wrote:

Hey Andrew,

Can you be a bit more specific, having trouble referencing this one problem
I ran into.

-Neil

On Sat, Oct 8, 2011 at 1:12 PM, Andrew Fecheyr <
reply@reply.github.com>wrote:

@nas887: how did you fix it?

Reply to this email directly or view it on GitHub:
#1339 (comment)

Reply to this email directly or view it on GitHub:
#1339 (comment)

@nas887
Copy link

nas887 commented Oct 9, 2011

Hi Andrew,

I'm very new to rails but working really hard.

My error was a simple configuration error. I fixed it by updating the URL that the callback was pointing to.

-Neil

@avocade
Copy link
Contributor

avocade commented Oct 10, 2011

Getting same issue still, "can't connect to localhost 5432" when running rake assets:precompile. Using devise directly, not via activeadmin.

On rails 3.1.1.rc3.

@josevalim
Copy link
Contributor

Rails 3.1.1 final has a method called config.assets.initialize_on_precompile. If you set it to false, you should be good but it won't allow you to access model information on your assets (which you probably shouldn't anyway).

@avocade
Copy link
Contributor

avocade commented Oct 10, 2011

Setting this in application.rb is suggested I guess?

@josevalim
Copy link
Contributor

Yes, more info about it in the guides:

http://guides.rubyonrails.org/asset_pipeline.html

@joemsak
Copy link

joemsak commented Nov 12, 2011

@josevalim +1 on the application.rb fix thank you

@malclocke
Copy link

Is there likely to be any more work on fixing this? I have a gem I'd dearly like to use that needs config.assets.initialize_on_precompile = true (https://github.com/fnando/i18n-js) and devise needs it set to false.

i18n-js needs the environment loaded to access the Rails I18n object, which seems fairly valid to me.

@josevalim
Copy link
Contributor

Try updating orm_adapter in your bundle and set config.assets.initialize_on_precompile = true and see if Devise will be fine with it.

@malclocke
Copy link

orm_adapter is at 0.0.7, which seems to be the latest release. Or do you mean update to the github master?

@josevalim
Copy link
Contributor

That was it. If it still doesn't work, I can't think of any other alternatives for now.

@taimoor
Copy link

taimoor commented Feb 5, 2013

When I installed active_admin with devise I got this issue on heroku. Any help? @josevalim

@darthdeus
Copy link

I'm still having this with the latest devise and 3.2.13 :\

@travisjtodd
Copy link

This seems to be occurring again with Rails 4 and Ruby 2 now that config.assets.initialize_on_precompile = true has been removed from Rails 4.

I get the same error as above when putting a simple extra validation on the user model:

class User < ActiveRecord::Base
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable,
         :confirmable, :lockable, :timeoutable

  validates :terms_of_service, acceptance: true
end

@jfeldstein
Copy link

Still getting this issue with ActiveAdmin, Devise, Rails 4 and Heroku.

Was there ever a fix?

@moustafasamir
Copy link

it was fixed for me by adding attr_accessor :terms_of_service

@travisjtodd
Copy link

Thanks @moustafasamir Works!

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

No branches or pull requests