-
-
Notifications
You must be signed in to change notification settings - Fork 301
🐛 Fix empty resource file bug #2348
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
🐛 Fix empty resource file bug #2348
Conversation
|
Code Climate has analyzed commit 6d5b00d and detected 0 issues on this pull request. View more on Code Climate. |
|
Can you please remove all the style changes? |
1b36a25 to
9d61d92
Compare
Paul-Bob
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks great, thanks for the contribution!
I was thinking if we should use the rescue_from at the class level and avoid repeating the rescue on multiple methods
rescue_from ActiveRecord::NoDatabaseError, with: :no_database_error
def no_database_error
puts "Database not found, please create your database and regenerate the resource."
[]
endThe current state of the PR is good to merge IMO, just wondering about ☝️
| rescue ActiveRecord::NoDatabaseError | ||
| puts "Database not found, please create your database and regenerate the resource." | ||
| rescue ActiveRecord::ConnectionNotEstablished | ||
| puts "Database connection error, please create your database and regenerate the resource." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't these return emtpy arrays too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not on this method, only if the exception start being rescued on model_db_columns
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct; so I have moved the rescue to model_db_columns instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good move since that's the origin of the exception.
Ready to merge 👌
|
Thanks for the contribution @RocKhalil |
This PR fixes an issue when generating a resource and the database connection is not working.
Currently, it creates an empty file, but with catching the error, it will generate the file with the default template: