Skip to content

Fix generator command for nested (namespaced) rails engine #27550

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

Conversation

mtsmfm
Copy link
Contributor

@mtsmfm mtsmfm commented Jan 3, 2017

Summary

If we create nested (namespaced) rails engine such like bukkits-admin,
bin/rails g scaffold User name:string age:integer
will create
bukkits-admin/app/controllers/bukkits/users_controller.rb
but it should create
bukkits-admin/app/controllers/bukkits/admin/users_controller.rb.

Other Information

In #6643, we changed namespaced_path as root path
because we supposed application_controller is always in root
but nested rails engine's application_controller will not.

If we create nested (namespaced) rails engine such like bukkits-admin,
`bin/rails g scaffold User name:string age:integer`
will create
`bukkits-admin/app/controllers/bukkits/users_controller.rb`
but it should create
`bukkits-admin/app/controllers/bukkits/admin/users_controller.rb`.

In rails#6643, we changed `namespaced_path` as root path
because we supposed application_controller is always in root
but nested rails engine's application_controller will not.
@rails-bot
Copy link

r? @schneems

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

@rafaelfranca rafaelfranca merged commit 1e969bf into rails:master Jan 4, 2017
@mtsmfm mtsmfm deleted the fix-generator-command-for-nested-rails-engine branch January 4, 2017 02:46
end

def namespaced_path # :doc:
@namespaced_path ||= namespace.name.split("::").first.underscore
@namespaced_path ||= namespace.name.split("::").map(&:underscore)
Copy link
Member

Choose a reason for hiding this comment

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

Sorry. I had to revert because this method is public API and now it changes the return from a string to an array. Can you open a new PR keeping this method returning a string?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you open a new PR keeping this method returning a string?

Sure!

rafaelfranca added a commit that referenced this pull request Jan 4, 2017
…or-nested-rails-engine"

This reverts commit 1e969bf, reversing
changes made to a5041f2.

Reason: It breaks the public API
mtsmfm added a commit to mtsmfm/rails that referenced this pull request Jan 7, 2017
Rewrite rails#27550

085546d was reverted (b6ffb5e) because it change the return of `namespaced_path` from String to Array.

----------------

If we create nested (namespaced) rails engine such like bukkits-admin,
`bin/rails g scaffold User name:string age:integer`
will create
`bukkits-admin/app/controllers/bukkits/users_controller.rb`
but it should create
`bukkits-admin/app/controllers/bukkits/admin/users_controller.rb`.

In rails#6643, we changed `namespaced_path` as root path
because we supposed application_controller is always in root
but nested rails engine's application_controller will not.
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.

5 participants