Swallow devise routing errors when re-setting database#2192
Swallow devise routing errors when re-setting database#2192nthj wants to merge 1 commit intoheartcombo:masterfrom nthj:master
Conversation
|
Hi @nthj, I wasn't able to reproduce this scenario locally but I know how annoying things like this can be, but instead of swallowing any possible error isn't better to emit a warning and skip the whole routes setup? Also, more input on this would be welcome. /cc @rodrigoflores @carlosantoniodasilva @josevalim |
|
Hmm, so you would like a backtrace? Or a one-line warning? Or just skip route set up on db:migrate entirely, whether an error is thrown or not?
|
|
@nthj sorry for taking so long on this. Can you provide an application that reproduces the issue? Calling Thank you. |
|
I'm having the same exact issue. Rake db loads environment, which loads routes, which upon calling devise_for :users , loads the model, which tries to load the fields. Chicken and egg The lines in question goes to a scope like this: |
|
@whoisjake can you provide an application that reproduces the issue? |
|
Yup! Just created it: https://github.com/whoisjake/devise_model_failure Easy to reproduce, in fact, edit user.rb to include a scope like: BOOM CRASH |
|
Oh I guess I didn't check in the Gemfile.lock https://github.com/whoisjake/devise_model_failure/blob/master/Gemfile.lock |
|
@whoisjake thanks a lot. I managed to reproduce the error and the |
|
So apparently the use of those types of scopes is "deprecated" in Rails edge... https://github.com/rails/rails/blob/master/activerecord/lib/active_record/scoping/named.rb#L145 11 months ago... might have snuck in between 3.2.11 and 3.2.12 as that's a change I recently made... |
|
Ok, nope, 3.2.12 does not have the deprecation, but this might have been there all along anyway... https://github.com/rails/rails/blob/v3.2.12/activerecord/lib/active_record/scoping/named.rb |
|
Yeah, I was thinking about just suggesting to use lambda scopes. Since it |
|
Yeah, I mean, I can do that... but the issue is still there as with 3.2.12 it's a perfectly valid way to do scopes. I'll probably just change my scopes instead of waiting around. Good luck! |
|
Ok, so I have confirmed that it's not a change in Devise. I went through each version back and the issue persisted. Upon changing from Rails 3.2.12 back to 3.2.11, it fails. |
|
I believe its this: When the WHERE clause is an integer, it goes out to the schema cache... So thanks. Probably should close this out... |
|
@whoisjake yes, and there's already some discussions about this on the Rails issue tracker. Thanks a lot for your help on digging this. @nthj are you on the same scenario with Devise + Rails 3.2.12? If so, I think we can close this one. |
|
Related to rails/rails#9290 |
|
Well looks like others came to the same conclusion! Thanks y'all |
I frequently run 'rake db:migrate:reset db:seed' when developing, to get back to my default mock-up state. Unfortunately, Devise assumes that the database table should exist at this point, and throws a SQL error. For example:
Since I'm trying to re-set the database, this is frustrating. I have to comment out the "devise_for" line in my routes.rb, run my migrations, then un-comment the devise_for line again.
This pull request simply swallows any exceptions from devise_for when running db:migrate.