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

Nested scaffold should be fine #30729

Merged
merged 1 commit into from
Sep 27, 2017
Merged

Conversation

yalab
Copy link
Contributor

@yalab yalab commented Sep 27, 2017

Summary

I run $ ./bin/rails g scaffold_conroller admin/users --model-name=User
Its works fine but redirect or link url is wrong.
I fixed it.

@rails-bot
Copy link

Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @javan (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

This repository is being automatically checked for code quality issues using Code Climate. You can see results for this analysis in the PR status below. Newly introduced issues should be fixed before a Pull Request is considered ready to review.

Please see the contribution instructions for more information.

@javan javan removed their assignment Sep 27, 2017
@tenderlove tenderlove merged commit 9c833ba into rails:master Sep 27, 2017
y-yagi added a commit to y-yagi/rails that referenced this pull request Nov 5, 2017
Currently, namespaced scaffold generator will generate an incorrect path
and the generated file will not work properly.

```
$ ./bin/rails g scaffold admin/user
$ ./bin/rails db:migrate
$  ./bin/rails t test/controllers
# Running:

E

Error:
Admin::UsersControllerTest#test_should_create_admin_user:
NameError: undefined local variable or method `admin_admin_users_url' for #<Admin::UsersControllerTest:0x000055a59f25ff68>
Did you mean?  admin_users
    test/controllers/admin/users_controller_test.rb:20:in `block (2 levels) in <class:UsersControllerTest>'
    test/controllers/admin/users_controller_test.rb:19:in `block in <class:UsersControllerTest>'

bin/rails test test/controllers/admin/users_controller_test.rb:18
```

This is because combine `controller_class_path` and `singular_table_name`
to generate route.
https://github.com/rails/rails/blob/360698aa245b45349d1d1b12e1afb34759515e69/railties/lib/rails/generators/named_base.rb#L172

Normally, if using namspaced generator, table name already contains
namespace. Therefore, adding `controller_class_path` adds extra namespace.
Since it is special only when explicitly specifying `model-name`, it is
modified to change the value only when `model-name`is specified.

Follow up of rails#30729
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants