-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Comments
+1 Have the same issue. Using Heroku Postgres on production. |
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. |
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. |
It looks like the latest 3.1-stable branch fixes the has_and_belongs_to_many app. It seems the devise_for method seems to be exposing underlying stuff out. Not sure if there's anything to be done? |
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? |
/cc @hone |
@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 |
Potentially fixed the issue here: You will need both devise and rails 3-1-stable branch in order to fix the issue over heroku. Thanks for everyone's help. |
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" |
@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 |
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. |
I changed the database to a non-existing database and here is the trace.
|
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? |
Please try again with Rails 3-1-stable branch. I have pushed a potential fix to Rails. |
Hi Jose, I'm having the same issue and have upgraded to 3-1. No luck. |
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. |
Thanks Jose, appreciate the help. Was able to figure it out after all. |
@nas887: how did you fix it? |
Hey Andrew, Can you be a bit more specific, having trouble referencing this one problem -Neil On Sat, Oct 8, 2011 at 1:12 PM, Andrew Fecheyr <
|
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:
|
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 |
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. |
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). |
Setting this in application.rb is suggested I guess? |
Yes, more info about it in the guides: |
@josevalim +1 on the application.rb fix thank you |
Is there likely to be any more work on fixing this? I have a gem I'd dearly like to use that needs i18n-js needs the environment loaded to access the Rails I18n object, which seems fairly valid to me. |
Try updating orm_adapter in your bundle and set |
orm_adapter is at 0.0.7, which seems to be the latest release. Or do you mean update to the github master? |
That was it. If it still doesn't work, I can't think of any other alternatives for now. |
When I installed active_admin with devise I got this issue on heroku. Any help? @josevalim |
I'm still having this with the latest devise and 3.2.13 :\ |
This seems to be occurring again with Rails 4 and Ruby 2 now that I get the same error as above when putting a simple extra validation on the user model:
|
Still getting this issue with ActiveAdmin, Devise, Rails 4 and Heroku. Was there ever a fix? |
it was fixed for me by adding attr_accessor :terms_of_service |
Thanks @moustafasamir Works! |
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
The text was updated successfully, but these errors were encountered: