Closed ebihara99999 closed 6 years ago
This fix is constrained to those versions of ActiveRecord that have that error class, so I can't merge this without some additional checks there. Also, there is a built-in option to skip the database check already which should avoid this error.
Thank you for the comment!
Do you mean the built-in option by Skipping flag column check referred to in README.md?
The feature seems to require users to set the flag false at first, and then to set the flag true once database creation is finished. It would be somehow inconvenient. I personally think this PR is better in the view of avoiding the error in database creation.
If you would review again when I reflect your correction, check more errors than ActiveRecord::NoDatabaseError
, I will check other errors and add them if there is.
@pboling
NoDatabaseError
is introduced in 4.1 stable branch. Before that, there seems no codes handling kind of error.
Do you think there is necessity to check more?
@ebihara99999 Sorry if I wasn't clear enough. The current gem supports Rails down to 2.3. I would like to shed all version of Rails prior to 4.2 in a 1.0 release, but I haven't had time to work on that.
Because this gem supports 2.3 we can't introduce a change that would break on any version prior to 4.1. The gem needs to continue to work on older rails until that support is officially dropped.
If we reference an error class in the code that doesn't exist in earlier versions of rails, then projects on those old version will raise an error about an undefined constant, or a NameError. We would need to have a guard that checks for the existence of the constant before trying to use the constant.
@pboling Thanks, I got the point. Would you review again?
@ebihara99999 The latest change is great. Any idea about the failing build?
@pboling I'll look into it when I have time.
@ebihara99999 I have fixed the failing build issues on master. Thanks!
What happened?
rails db:create
fails with the following trace:#has_flags
is called in/app/myproject/app/models/product.rb:92
.Envirinment
How to fix
Catch
ActiveRecord::NoDatabaseError
and do nothing. It fails when runrails db:create
because#connection
raisesActiveRecord::NoDatabaseError
. It's not necessary to check whathas_flags
does if it's in database creation.