-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Model Generator Source Paths Should Allow for Customization #47181
Model Generator Source Paths Should Allow for Customization #47181
Conversation
762173d
to
552d1b5
Compare
43a28b2
to
a1ba618
Compare
@rafaelfranca Based on #13972 (comment) , mind taking a look?
|
Since this patch is almost the same as before (except with tests), I think it's good to add the original author as well to the commit. You can do this by adding this to the bottom of your commit message:
Which you can find on the original patch: Thanks! |
a1a7e3a
to
bda488a
Compare
@spencerneste Can you amend the commit message and remove the extra commit data from git? Also for the co-author to work there can't be any whitespace/tabs before the line. LMK if you need help! I think I can commit directly to this branch if necessary 🙏 |
bda488a
to
b473b64
Compare
@zzak Anything else needed here ? Thanks! |
@rafaelfranca @zzak Mind taking a look ? |
@@ -58,6 +60,16 @@ def parent_class_name | |||
end | |||
end | |||
|
|||
def ensure_migration_source_paths |
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.
This is pretty much reimplementing find_in_source_paths
.
Can't we just use it?
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.
Thanks for the review @rafaelfranca ! find_in_source_paths
is being called by migration_template so we are using it.
The issue this PR is solving is that source_paths
do not contain the correct paths for customizable create_table_migration.rb.tt
templates. So the solution is to include the template_paths from the migration generator, as well a "special" path to preserve existing functionality.
I'm open to any feedback to get this functionality fixed 😃
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.
Rails::Generators.templates_path
should already be in the source_paths. We don't do any of this work in other generators and they just work.
I think the source of the problem is that we are using relative path to find the template. What we can do is append the migration template to the source path in this generator and change back the relative path.
c6111bc
to
2c00779
Compare
2c00779
to
87dbe37
Compare
@rafaelfranca @zzak Anything else needed? Thanks! |
@rafaelfranca @zzak Friendly reminder for review. Thanks! |
@zzak Are you able to give this a review? 🙏 |
Mind taking a quick look @rafaelfranca ? Would love to get this functionality restored, thanks ! |
Co-authored-by: Joshua Flanagan <joshuaflanagan@gmail.com>
7e41b3a
to
8d9446b
Compare
…he migration template
8d9446b
to
b070c4d
Compare
Motivation / Background
This Pull Request has been created because #13972 was closed. It has the same content as the mentioned PR, with the addition of a test that would fail without the new code, and an instance variable initialization to silence a warning.
Detail
This Pull Request changes which source paths to consider when using the rails model generator. More detail can be found here: #13972 (comment)
Checklist
Before submitting the PR make sure the following are checked:
[Fix #issue-number]