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

Fixed bug that occurred when scaffold generated a model with nested namespace. #43365

Merged
merged 1 commit into from
Nov 22, 2021

Conversation

alpaca-tc
Copy link
Contributor

@alpaca-tc alpaca-tc commented Oct 3, 2021

Summary

As a follow-up to #41210 , this commit adds a bug fix for generating scaffold with nested model
incorrectly creating a partial view.

In Rails 7.0.0.alpha2, . /bin/rails g scaffold admin/accont will generate app/views/admin/_admin_account, but the correct path is app/views/admin/_account.

$ ./bin/rails generate scaffold admin/account
$ ./bin/rails db:migrate
$ ./bin/rails runner 'Admin::Account.create!'
$ open http://127.0.0.1:3000/admin/accounts

スクリーンショット 2021-10-11 14 57 44

Assuming that the @admin_accounts instance variable contains an instance of the Admin::Account model, this will use admin/accounts/_account.html.erb to render it and will pass the local variable account into the partial. Unfortunately, rails7.0.0.alpha generated admin/accounts/_admin_account.html.erb and use admin_account as local variable in the partial.

Other Information

@pirj
Copy link
Contributor

pirj commented Nov 17, 2021

Does it need a test case to prevent regressions?

…amespace.

When I called `rails g scaffold admin/account`, scaffold generated wrong views.
Because `render @admin_accounts` expects a partial view of `admin/accounts/_account`,
but scaffold generates `admin/accounts/_admin_account`, so the template is not found.
@alpaca-tc
Copy link
Contributor Author

@pirj Added test to prevent regressions 👍 and force pushed.

@rafaelfranca rafaelfranca merged commit ade4e7a into rails:main Nov 22, 2021
@alpaca-tc alpaca-tc deleted the fixed_scaffold branch November 24, 2021 07:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants