Skip to content

Commit

Permalink
Route to the full namespaced resource when generating a controller.
Browse files Browse the repository at this point in the history
For example:
rails generate controller foo/bar index

should generate:
get 'foo/bar/index'

previously it generated:
get 'bar/index'
  • Loading branch information
parndt committed Aug 22, 2012
1 parent d5fe242 commit 2fa841a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Expand Up @@ -9,8 +9,9 @@ def create_controller_files
end

def add_routes
route_path = (class_path | [file_name]).join '/'
actions.reverse.each do |action|
route %{get "#{file_name}/#{action}"}
route %{get "#{route_path}/#{action}"}
end
end

Expand Down
3 changes: 2 additions & 1 deletion railties/test/generators/namespaced_generators_test.rb
Expand Up @@ -60,7 +60,8 @@ def test_invokes_default_template_engine

def test_routes_should_not_be_namespaced
run_generator
assert_file "config/routes.rb", /get "account\/foo"/, /get "account\/bar"/
assert_file "config/routes.rb", /get "test_app\/account\/foo"/,
/get "test_app\/account\/bar"/
end
#
def test_invokes_default_template_engine_even_with_no_action
Expand Down

0 comments on commit 2fa841a

Please sign in to comment.