plataformatec/devise — Issue #1373: Asset pre-compilation fails when using Devise and named scope with lambda in User model
Author: ljfc
Created: 2011-10-10 20:25:32+00:00
State: open

Apologies if this is not in fact a problem with Devise, but `lib/devise.rb`, `lib/devise/mapping.rb` and `lib/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 error `Could 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