Changeset 6485
- Timestamp:
- 03/28/07 21:55:40 (1 year ago)
- Files:
-
- trunk/actionpack/CHANGELOG (modified) (1 diff)
- trunk/actionpack/lib/action_controller/resources.rb (modified) (5 diffs)
- trunk/actionpack/test/controller/resources_test.rb (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/CHANGELOG
r6480 r6485 1 1 *SVN* 2 3 * Dropped the use of ; as a separator of non-crud actions on resources and went back to the vanilla slash. It was a neat idea, but lots of the non-crud actions turned out not to be RPC (as the ; was primarily intended to discourage), but legitimate sub-resources, like /parties/recent, which didn't deserve the uglification of /parties;recent. Further more, the semicolon caused issues with caching and HTTP authentication in Safari. Just Not Worth It [DHH] 2 4 3 5 * Added that FormTagHelper#submit_tag will return to its original state if the submit fails and you're using :disable_with [DHH] trunk/actionpack/lib/action_controller/resources.rb
r6232 r6485 200 200 # * <tt>:collection</tt> -- add named routes for other actions that operate on the collection. 201 201 # Takes a hash of <tt>#{action} => #{method}</tt>, where method is <tt>:get</tt>/<tt>:post</tt>/<tt>:put</tt>/<tt>:delete</tt> 202 # or <tt>:any</tt> if the method does not matter. These routes map to a URL like /messages ;rss, with a route of rss_messages_url.202 # or <tt>:any</tt> if the method does not matter. These routes map to a URL like /messages/rss, with a route of rss_messages_url. 203 203 # * <tt>:member</tt> -- same as :collection, but for actions that operate on a specific member. 204 204 # * <tt>:new</tt> -- same as :collection, but for actions that operate on the new resource action. … … 212 212 # 213 213 # map.resources :messages, :collection => { :rss => :get } 214 # # --> GET /messages ;rss (maps to the #rss action)214 # # --> GET /messages/rss (maps to the #rss action) 215 215 # # also adds a named route called "rss_messages" 216 216 # 217 217 # map.resources :messages, :member => { :mark => :post } 218 # # --> POST /messages/1 ;mark (maps to the #mark action)218 # # --> POST /messages/1/mark (maps to the #mark action) 219 219 # # also adds a named route called "mark_message" 220 220 # 221 221 # map.resources :messages, :new => { :preview => :post } 222 # # --> POST /messages/new ;preview (maps to the #preview action)222 # # --> POST /messages/new/preview (maps to the #preview action) 223 223 # # also adds a named route called "preview_new_message" 224 224 # 225 225 # map.resources :messages, :new => { :new => :any, :preview => :post } 226 # # --> POST /messages/new ;preview (maps to the #preview action)226 # # --> POST /messages/new/preview (maps to the #preview action) 227 227 # # also adds a named route called "preview_new_message" 228 228 # # --> /messages/new can be invoked via any request method … … 332 332 actions.each do |action| 333 333 action_options = action_options_for(action, resource, method) 334 map.named_route("#{resource.name_prefix}#{action}_#{resource.plural}", "#{resource.path} ;#{action}", action_options)335 map.named_route("formatted_#{resource.name_prefix}#{action}_#{resource.plural}", "#{resource.path} .:format;#{action}", action_options)334 map.named_route("#{resource.name_prefix}#{action}_#{resource.plural}", "#{resource.path}/#{action}", action_options) 335 map.named_route("formatted_#{resource.name_prefix}#{action}_#{resource.plural}", "#{resource.path}/#{action}.:format", action_options) 336 336 end 337 337 end … … 362 362 map.named_route("formatted_#{resource.name_prefix}new_#{resource.singular}", "#{resource.new_path}.:format", action_options) 363 363 else 364 map.named_route("#{resource.name_prefix}#{action}_new_#{resource.singular}", "#{resource.new_path} ;#{action}", action_options)365 map.named_route("formatted_#{resource.name_prefix}#{action}_new_#{resource.singular}", "#{resource.new_path} .:format;#{action}", action_options)364 map.named_route("#{resource.name_prefix}#{action}_new_#{resource.singular}", "#{resource.new_path}/#{action}", action_options) 365 map.named_route("formatted_#{resource.name_prefix}#{action}_new_#{resource.singular}", "#{resource.new_path}/#{action}.:format", action_options) 366 366 end 367 367 end … … 373 373 actions.each do |action| 374 374 action_options = action_options_for(action, resource, method) 375 map.named_route("#{resource.name_prefix}#{action}_#{resource.singular}", "#{resource.member_path} ;#{action}", action_options)376 map.named_route("formatted_#{resource.name_prefix}#{action}_#{resource.singular}", "#{resource.member_path} .:format;#{action}",action_options)375 map.named_route("#{resource.name_prefix}#{action}_#{resource.singular}", "#{resource.member_path}/#{action}", action_options) 376 map.named_route("formatted_#{resource.name_prefix}#{action}_#{resource.singular}", "#{resource.member_path}/#{action}.:format",action_options) 377 377 end 378 378 end trunk/actionpack/test/controller/resources_test.rb
r6232 r6485 104 104 def test_with_collection_action 105 105 rss_options = {:action => 'rss'} 106 rss_path = "/messages ;rss"106 rss_path = "/messages/rss" 107 107 actions = { 'a' => :put, 'b' => :post, 'c' => :delete } 108 108 … … 112 112 113 113 actions.each do |action, method| 114 assert_recognizes(options.merge(:action => action), :path => "/messages ;#{action}", :method => method)114 assert_recognizes(options.merge(:action => action), :path => "/messages/#{action}", :method => method) 115 115 end 116 116 end … … 119 119 assert_named_route rss_path, :rss_messages_path, rss_options 120 120 actions.keys.each do |action| 121 assert_named_route "/messages ;#{action}", "#{action}_messages_path", :action => action121 assert_named_route "/messages/#{action}", "#{action}_messages_path", :action => action 122 122 end 123 123 end … … 129 129 with_restful_routing :messages, :member => { :mark => method } do 130 130 mark_options = {:action => 'mark', :id => '1'} 131 mark_path = "/messages/1 ;mark"131 mark_path = "/messages/1/mark" 132 132 assert_restful_routes_for :messages do |options| 133 133 assert_recognizes(options.merge(mark_options), :path => mark_path, :method => method) … … 146 146 %w(mark unmark).each do |action| 147 147 action_options = {:action => action, :id => '1'} 148 action_path = "/messages/1 ;#{action}"148 action_path = "/messages/1/#{action}" 149 149 assert_restful_routes_for :messages do |options| 150 150 assert_recognizes(options.merge(action_options), :path => action_path, :method => method) … … 162 162 with_restful_routing :messages, :new => { :preview => :post } do 163 163 preview_options = {:action => 'preview'} 164 preview_path = "/messages/new ;preview"164 preview_path = "/messages/new/preview" 165 165 assert_restful_routes_for :messages do |options| 166 166 assert_recognizes(options.merge(preview_options), :path => preview_path, :method => :post) … … 253 253 with_singleton_resources :account, :member => { :reset => method } do 254 254 reset_options = {:action => 'reset'} 255 reset_path = "/account ;reset"255 reset_path = "/account/reset" 256 256 assert_singleton_routes_for :account do |options| 257 257 assert_recognizes(options.merge(reset_options), :path => reset_path, :method => method) … … 270 270 %w(reset disable).each do |action| 271 271 action_options = {:action => action} 272 action_path = "/account ;#{action}"272 action_path = "/account/#{action}" 273 273 assert_singleton_routes_for :account do |options| 274 274 assert_recognizes(options.merge(action_options), :path => action_path, :method => method) … … 370 370 member_path = "#{collection_path}/1" 371 371 new_path = "#{collection_path}/new" 372 edit_member_path = "#{member_path} ;edit"373 formatted_edit_member_path = "#{member_path} .xml;edit"372 edit_member_path = "#{member_path}/edit" 373 formatted_edit_member_path = "#{member_path}/edit.xml" 374 374 375 375 with_options(options[:options]) do |controller| … … 423 423 assert_named_route "#{full_prefix}/new", "#{name_prefix}new_#{singular_name}_path", options[:options] 424 424 assert_named_route "#{full_prefix}/1", "#{name_prefix}#{singular_name}_path", options[:options].merge(:id => '1') 425 assert_named_route "#{full_prefix}/1 ;edit", "#{name_prefix}edit_#{singular_name}_path", options[:options].merge(:id => '1')425 assert_named_route "#{full_prefix}/1/edit", "#{name_prefix}edit_#{singular_name}_path", options[:options].merge(:id => '1') 426 426 assert_named_route "#{full_prefix}.xml", "formatted_#{name_prefix}#{controller_name}_path", options[:options].merge( :format => 'xml') 427 427 assert_named_route "#{full_prefix}/new.xml", "formatted_#{name_prefix}new_#{singular_name}_path", options[:options].merge( :format => 'xml') 428 428 assert_named_route "#{full_prefix}/1.xml", "formatted_#{name_prefix}#{singular_name}_path", options[:options].merge(:id => '1', :format => 'xml') 429 assert_named_route "#{full_prefix}/1 .xml;edit", "formatted_#{name_prefix}edit_#{singular_name}_path", options[:options].merge(:id => '1', :format => 'xml')429 assert_named_route "#{full_prefix}/1/edit.xml", "formatted_#{name_prefix}edit_#{singular_name}_path", options[:options].merge(:id => '1', :format => 'xml') 430 430 yield options[:options] if block_given? 431 431 end … … 436 436 full_path = "/#{options[:path_prefix]}#{singleton_name}" 437 437 new_path = "#{full_path}/new" 438 edit_path = "#{full_path} ;edit"439 formatted_edit_path = "#{full_path} .xml;edit"438 edit_path = "#{full_path}/edit" 439 formatted_edit_path = "#{full_path}/edit.xml" 440 440 441 441 with_options options[:options] do |controller| … … 477 477 assert_named_route "#{full_path}", "#{singleton_name}_path", options[:options] 478 478 assert_named_route "#{full_path}/new", "new_#{singleton_name}_path", options[:options] 479 assert_named_route "#{full_path} ;edit", "edit_#{singleton_name}_path", options[:options]479 assert_named_route "#{full_path}/edit", "edit_#{singleton_name}_path", options[:options] 480 480 assert_named_route "#{full_path}.xml", "formatted_#{singleton_name}_path", options[:options].merge(:format => 'xml') 481 481 assert_named_route "#{full_path}/new.xml", "formatted_new_#{singleton_name}_path", options[:options].merge(:format => 'xml') 482 assert_named_route "#{full_path} .xml;edit", "formatted_edit_#{singleton_name}_path", options[:options].merge(:format => 'xml')482 assert_named_route "#{full_path}/edit.xml", "formatted_edit_#{singleton_name}_path", options[:options].merge(:format => 'xml') 483 483 end 484 484