Skip to content
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

Stop creating ApplicationRecord on model generation #29916

Merged
merged 1 commit into from Jul 25, 2017

Conversation

lugray
Copy link
Contributor

@lugray lugray commented Jul 24, 2017

Fixes #29407.

Summary

When generating models, we created ApplicationRecord in the default location if no file existed there. That was annoying for people who moved it to somewhere else in the autoload path. At this point, the vast majority of apps should have either run the upgrade script or generated a model since upgrading. For those that haven't the error message after generating a new model should be helpful:

NameError: uninitialized constant ApplicationRecord

Other Information

To ease friction in that case, this also adds a generator for ApplicationRecord.

@rails-bot
Copy link

r? @eileencodes

(@rails-bot has picked a reviewer for you, use r? to override)

Copy link
Member

@rafaelfranca rafaelfranca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change will need a CHANGELOG entry

@@ -0,0 +1,24 @@
require "rails/generators/active_record"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing frozen string literal comment

@lugray lugray force-pushed the stop_generating_application_record branch 2 times, most recently from 8895f23 to 45ab73f Compare July 24, 2017 19:56
@lugray
Copy link
Contributor Author

lugray commented Jul 24, 2017

Updated.

@lugray lugray force-pushed the stop_generating_application_record branch from 45ab73f to bdbd5fd Compare July 25, 2017 00:38
When generating models, we created ApplicationRecord in the default
location if no file existed there.  That was annoying for people who
moved it to somewhere else in the autoload path.  At this point, the
vast majority of apps should have either run the upgrade script or
generated a model since upgrading.  For those that haven't the error
message after generating a new model should be helpful:

   NameError: uninitialized constant ApplicationRecord

To ease friction in that case, this also adds a generator for
ApplicationRecord.
@lugray lugray force-pushed the stop_generating_application_record branch from bdbd5fd to 75ccdfe Compare July 25, 2017 01:22
@eileencodes eileencodes merged commit ec21b97 into rails:master Jul 25, 2017
@eileencodes
Copy link
Member

Thanks @lugray! And also thank you for writing an excellent commit message 😸

@lugray lugray deleted the stop_generating_application_record branch July 25, 2017 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants