diff options
author | José Valim <jose.valim@gmail.com> | 2011-07-28 11:10:23 -0700 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-07-28 11:10:23 -0700 |
commit | b295ea1362bdd5033cfb5602985c0c11f37e2ae0 (patch) | |
tree | 3c63adc1d28c5c931de82e09627780437577144c | |
parent | adce9b4ca30e13ca2f952cee5805f06e31c4ff70 (diff) | |
parent | a5f57a7ef2af05ac1f7b919040e10c1b21de8e56 (diff) | |
download | rails-b295ea1362bdd5033cfb5602985c0c11f37e2ae0.tar.gz rails-b295ea1362bdd5033cfb5602985c0c11f37e2ae0.tar.bz2 rails-b295ea1362bdd5033cfb5602985c0c11f37e2ae0.zip |
Merge pull request #2330 from thedarkone/resources-router-fix
Inline resources router fix
-rw-r--r-- | actionpack/lib/action_dispatch/routing/mapper.rb | 15 | ||||
-rw-r--r-- | actionpack/test/controller/resources_test.rb | 9 |
2 files changed, 16 insertions, 8 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index 53374949ae..bd04f48c00 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -872,9 +872,9 @@ module ActionDispatch def initialize(entities, options = {}) @name = entities.to_s - @path = (options.delete(:path) || @name).to_s - @controller = (options.delete(:controller) || @name).to_s - @as = options.delete(:as) + @path = (options[:path] || @name).to_s + @controller = (options[:controller] || @name).to_s + @as = options[:as] @options = options end @@ -936,12 +936,11 @@ module ActionDispatch DEFAULT_ACTIONS = [:show, :create, :update, :destroy, :new, :edit] def initialize(entities, options) + super + @as = nil - @name = entities.to_s - @path = (options.delete(:path) || @name).to_s - @controller = (options.delete(:controller) || plural).to_s - @as = options.delete(:as) - @options = options + @controller = (options[:controller] || plural).to_s + @as = options[:as] end def plural diff --git a/actionpack/test/controller/resources_test.rb b/actionpack/test/controller/resources_test.rb index 6ea492cf8b..3b1b5fc3ec 100644 --- a/actionpack/test/controller/resources_test.rb +++ b/actionpack/test/controller/resources_test.rb @@ -91,6 +91,15 @@ class ResourcesTest < ActionController::TestCase end end + def test_multiple_resources_with_options + expected_options = {:controller => 'threads', :action => 'index'} + + with_restful_routing :messages, :comments, expected_options.slice(:controller) do + assert_recognizes(expected_options, :path => 'comments') + assert_recognizes(expected_options, :path => 'messages') + end + end + def test_with_custom_conditions with_restful_routing :messages, :conditions => { :subdomain => 'app' } do assert @routes.recognize_path("/messages", :method => :get, :subdomain => 'app') |