Skip to content
Browse files

Remove variables when determining the controller for match shorthand …

…routes. Close #7554
  • Loading branch information...
1 parent cde326b commit 8abc68cb33699281472f3ed279275bb0cdad9918 @senny committed Oct 13, 2012
View
7 actionpack/CHANGELOG.md
@@ -1,5 +1,10 @@
## Rails 4.0.0 (unreleased) ##
+* Remove variables when determining the controller for match shorthand routes.
+ Fix #7554
+
+ *Yves Senn*
+
* `date_select` helper accepts `with_css_classes: true` to add css classes similar with type
of generated select tags.
@@ -18,7 +23,7 @@
*Josh Peek*
-* `assert_template` can be used to assert on the same template with different locals
+* `assert_template` can be used to assert on the same template with different locals.
Fix #3675
*Yves Senn*
View
2 actionpack/lib/action_dispatch/routing/mapper.rb
@@ -84,7 +84,7 @@ def normalize_options!
if using_match_shorthand?(path_without_format, @options)
to_shorthand = @options[:to].blank?
- @options[:to] ||= path_without_format.gsub(/\(.*\)/, "")[1..-1].sub(%r{/([^/]*)$}, '#\1')
+ @options[:to] ||= path_without_format.gsub(/\(.*\)/, "").gsub(/\/:[^\/]+/, '')[1..-1].sub(%r{/([^/]*)$}, '#\1')
end
@options.merge!(default_controller_and_action(to_shorthand))
View
10 actionpack/test/dispatch/routing_test.rb
@@ -347,6 +347,10 @@ def self.call(params, request)
root :to => 'projects#index'
end
+ scope ':locale' do
+ match 'questions/new', via: [:get]
+ end
+
scope :only => [:index, :show] do
resources :products, :constraints => { :id => /\d{4}/ } do
root :to => "products#root"
@@ -1411,6 +1415,12 @@ def test_nested_optional_path_shorthand
assert_equal 'en', @request.params[:locale]
end
+ def test_match_within_scope
+ get '/de/questions/new'
+ assert_equal 'questions#new', @response.body
+ assert_equal 'de', @request.params[:locale]
+ end
+
def test_default_params
get '/inline_pages'
assert_equal 'home', @request.params[:id]

0 comments on commit 8abc68c

Please sign in to comment.
Something went wrong with that request. Please try again.