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
Asset pre-compilation fails when using Devise and named scope with lambda in User model #1373
Comments
Can you please push to Github a small application that reproduces the error? Also, please include Devise and Rails versions in your reports and please ensure that you are running on latest Devise and Rails 3.1. |
Apologies for the omissions José, I am relatively new to GitHub. I have spent the past hour or so looking into this, and I have a few more pieces of information. The application you wanted is here: https://github.com/ljfc/devise_error Recreating the error should be just a matter of running Indeed, the example will not even permit the initial A few notes: Adding the Heroku fix The problem was apparent in Devise 1.4.5, and upgrading to 1.4.8 has also not helped. The example app uses 1.4.8. The example app uses Rails 3.1.1, and also displays the known Rack 1.3.4 warning My original app is still using Rails 3.1.0 for the moment, but this error seems to occur with both versions. I have included the same scope code in a similar small application using a simple has_secure_password approach rather than Devise, and it doesn't give the same errors, so it does seem to be something to do with the code Devise adds. A final note: I have fixed this in my main app by replacing the scope-with-lambda with a class method, which I believe is now best practice anyway. So I am not under pressure to fix this personally, although it would still be good to know if there is something obvious wrong. Let me know if there is anything else I can provide, but please bear in mind I am on UK time, so will not respond until tomorrow now. |
Ok, thank you very much for the app and the debugging you have done so far. Please keep me posted if you find anything else, I will take a look at your app hopefully later this week. |
hi, https://github.com/ljfc/devise_error/blob/master/app/models/user.rb#L3 if you rename your scope ":find_by_something" in ":by_something", then it works. hope this helps. |
Hi Matt, Thanks for the tip. I guess I just thought it was functionally equivalent to the generated Could this actually be causing the error? The lambda function does work, it just causes certain Leo |
Sorry, I can't explain the exact technical cause of the error in your particular case. Best, Matt |
Okay, cheers Matt. |
Apologies if this is not in fact a problem with Devise, but
lib/devise.rb
,lib/devise/mapping.rb
andlib/devise/rails/routes.rb
appear in the backtrace, so I thought it was worth letting you know.The problem appeared when I added a named scope incorporating a lambda function to the User model that uses devise:
scope :find_by_skill_offered, lambda { |skill_id| joins(:skills).where("user_skills.offered = ? AND skills.id = ?", :true, skill_id) }
Now calling
rake assets:precompile
fails, both locally and on a development server, with the errorCould not find table 'users'
.Full backtrace of the rake error here: https://gist.github.com/1276348
I have also asked about this on StackOverflow, as I can see that this may not be a bug in Devise, but I have tried a few workarounds elsewhere relating to other rake tasks failing in the same way, and a similar error relating to factory_girl, but none of them seem to work in this case.
http://stackoverflow.com/questions/7716900/rails-capistrano-deploy-error-fails-on-rake-assetprecompile-in-named-scope-wit
The text was updated successfully, but these errors were encountered: