Permalink
Browse files

Removing to_shorthand from default_controller_and_action. Fixes #6497

When using shortcut routes inside an engine the "to_shorthand" variable
is set to true, causing the module scope of the route to not be applied.
  • Loading branch information...
1 parent 731d809 commit 641ea6925790771acb6e91b73f9efa6ded834761 @Draiken Draiken committed Sep 17, 2012
View
14 actionpack/CHANGELOG.md
@@ -4,9 +4,19 @@
*Yves Senn*
-* Allow pass couple extensions to ActionView::Template.register_template_handler call. *Tima Maslyuchenko*
+* Allow pass couple extensions to `ActionView::Template.register_template_handler` call. *Tima Maslyuchenko*
-* Sprockets integration has been extracted from Action Pack and the `sprockets-rails`
+* Fixed a bug with shorthand routes scoped with the `:module` option not
+ adding the module to the controller as described in issue #6497.
+ This should now work properly:
+
+ scope :module => "engine" do
+ get "api/version" # routes to engine/api#version
+ end
+
+ *Luiz Felipe Garcia Pereira*
+
+* Sprockets integration has been extracted from Action Pack and the `sprockets-rails`
gem should be added to Gemfile (under the assets group) in order to use Rails asset
pipeline in future versions of Rails.
View
2 actionpack/lib/action_dispatch/routing/mapper.rb
@@ -182,7 +182,7 @@ def default_controller_and_action(to_shorthand=nil)
controller ||= default_controller
action ||= default_action
- unless controller.is_a?(Regexp) || to_shorthand
+ unless controller.is_a?(Regexp)
controller = [@scope[:module], controller].compact.join("/").presence
end
View
7 actionpack/test/dispatch/routing_test.rb
@@ -363,6 +363,7 @@ def self.call(params, request)
resources :errors, :shallow => true do
resources :notices
end
+ get 'api/version'
end
scope :path => 'api' do
@@ -1280,6 +1281,12 @@ def test_match_shorthand_inside_namespace
assert_equal 'account#shorthand', @response.body
end
+ def test_match_shorthand_with_module
+ assert_equal '/api/version', api_version_path
+ get '/api/version'
+ assert_equal 'api/api#version', @response.body
+ end
+
def test_dynamically_generated_helpers_on_collection_do_not_clobber_resources_url_helper
assert_equal '/replies', replies_path
end

0 comments on commit 641ea69

Please sign in to comment.