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

Merged
merged 1 commit into from Jan 4, 2017

Projects

None yet

5 participants

@mtsmfm
Contributor
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.

@mtsmfm mtsmfm Fix generator command for nested (namespaced) rails engine
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 #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.
085546d
@rails-bot

r? @schneems

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

@schneems schneems was assigned by rails-bot Jan 3, 2017
@maclover7 maclover7 added the railties label Jan 3, 2017
@rafaelfranca rafaelfranca merged commit 1e969bf into rails:master Jan 4, 2017

2 checks passed

codeclimate no new or fixed issues
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@mtsmfm mtsmfm deleted the mtsmfm:fix-generator-command-for-nested-rails-engine branch Jan 4, 2017
end
def namespaced_path # :doc:
- @namespaced_path ||= namespace.name.split("::").first.underscore
+ @namespaced_path ||= namespace.name.split("::").map(&:underscore)
@rafaelfranca
rafaelfranca Jan 4, 2017 Member

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?

@mtsmfm
mtsmfm Jan 4, 2017 Contributor

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

Sure!

@rafaelfranca rafaelfranca added a commit that referenced this pull request Jan 4, 2017
@rafaelfranca rafaelfranca Revert "Merge pull request #27550 from mtsmfm/fix-generator-command-f…
…or-nested-rails-engine"

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

Reason: It breaks the public API
b6ffb5e
@mtsmfm mtsmfm added a commit to mtsmfm/rails that referenced this pull request Jan 7, 2017
@mtsmfm mtsmfm Fix generator command for nested (namespaced) rails engine (take 2)
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 #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.
4459a18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment