Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 6485

Show
Ignore:
Timestamp:
03/28/07 21:55:40 (1 year ago)
Author:
david
Message:

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]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/CHANGELOG

    r6480 r6485  
    11*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] 
    24 
    35* 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  
    200200    # * <tt>:collection</tt> -- add named routes for other actions that operate on the collection. 
    201201    #   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. 
    203203    # * <tt>:member</tt> -- same as :collection, but for actions that operate on a specific member. 
    204204    # * <tt>:new</tt> -- same as :collection, but for actions that operate on the new resource action. 
     
    212212    #   
    213213    #   map.resources :messages, :collection => { :rss => :get } 
    214     #   # --> GET /messages;rss (maps to the #rss action) 
     214    #   # --> GET /messages/rss (maps to the #rss action) 
    215215    #   #     also adds a named route called "rss_messages" 
    216216    #  
    217217    #   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) 
    219219    #   #     also adds a named route called "mark_message" 
    220220    #  
    221221    #   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) 
    223223    #   #     also adds a named route called "preview_new_message" 
    224224    #  
    225225    #   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) 
    227227    #   #     also adds a named route called "preview_new_message" 
    228228    #   # --> /messages/new can be invoked via any request method 
     
    332332          actions.each do |action| 
    333333            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) 
    336336          end 
    337337        end 
     
    362362              map.named_route("formatted_#{resource.name_prefix}new_#{resource.singular}", "#{resource.new_path}.:format", action_options) 
    363363            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) 
    366366            end 
    367367          end 
     
    373373          actions.each do |action| 
    374374            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) 
    377377          end 
    378378        end 
  • trunk/actionpack/test/controller/resources_test.rb

    r6232 r6485  
    104104  def test_with_collection_action 
    105105    rss_options = {:action => 'rss'} 
    106     rss_path    = "/messages;rss" 
     106    rss_path    = "/messages/rss" 
    107107    actions = { 'a' => :put, 'b' => :post, 'c' => :delete } 
    108108 
     
    112112 
    113113        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) 
    115115        end 
    116116      end 
     
    119119        assert_named_route rss_path, :rss_messages_path, rss_options 
    120120        actions.keys.each do |action| 
    121           assert_named_route "/messages;#{action}", "#{action}_messages_path", :action => action 
     121          assert_named_route "/messages/#{action}", "#{action}_messages_path", :action => action 
    122122        end 
    123123      end 
     
    129129      with_restful_routing :messages, :member => { :mark => method } do 
    130130        mark_options = {:action => 'mark', :id => '1'} 
    131         mark_path    = "/messages/1;mark" 
     131        mark_path    = "/messages/1/mark" 
    132132        assert_restful_routes_for :messages do |options| 
    133133          assert_recognizes(options.merge(mark_options), :path => mark_path, :method => method) 
     
    146146        %w(mark unmark).each do |action| 
    147147          action_options = {:action => action, :id => '1'} 
    148           action_path    = "/messages/1;#{action}" 
     148          action_path    = "/messages/1/#{action}" 
    149149          assert_restful_routes_for :messages do |options| 
    150150            assert_recognizes(options.merge(action_options), :path => action_path, :method => method) 
     
    162162    with_restful_routing :messages, :new => { :preview => :post } do 
    163163      preview_options = {:action => 'preview'} 
    164       preview_path    = "/messages/new;preview" 
     164      preview_path    = "/messages/new/preview" 
    165165      assert_restful_routes_for :messages do |options| 
    166166        assert_recognizes(options.merge(preview_options), :path => preview_path, :method => :post) 
     
    253253      with_singleton_resources :account, :member => { :reset => method } do 
    254254        reset_options = {:action => 'reset'} 
    255         reset_path    = "/account;reset" 
     255        reset_path    = "/account/reset" 
    256256        assert_singleton_routes_for :account do |options| 
    257257          assert_recognizes(options.merge(reset_options), :path => reset_path, :method => method) 
     
    270270        %w(reset disable).each do |action| 
    271271          action_options = {:action => action} 
    272           action_path    = "/account;#{action}" 
     272          action_path    = "/account/#{action}" 
    273273          assert_singleton_routes_for :account do |options| 
    274274            assert_recognizes(options.merge(action_options), :path => action_path, :method => method) 
     
    370370      member_path                = "#{collection_path}/1" 
    371371      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
    374374 
    375375      with_options(options[:options]) do |controller| 
     
    423423      assert_named_route "#{full_prefix}/new",        "#{name_prefix}new_#{singular_name}_path",            options[:options] 
    424424      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') 
    426426      assert_named_route "#{full_prefix}.xml",        "formatted_#{name_prefix}#{controller_name}_path",    options[:options].merge(            :format => 'xml') 
    427427      assert_named_route "#{full_prefix}/new.xml",    "formatted_#{name_prefix}new_#{singular_name}_path",  options[:options].merge(            :format => 'xml') 
    428428      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') 
    430430      yield options[:options] if block_given? 
    431431    end 
     
    436436      full_path           = "/#{options[:path_prefix]}#{singleton_name}" 
    437437      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
    440440 
    441441      with_options options[:options] do |controller| 
     
    477477      assert_named_route "#{full_path}",          "#{singleton_name}_path",                options[:options] 
    478478      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] 
    480480      assert_named_route "#{full_path}.xml",      "formatted_#{singleton_name}_path",      options[:options].merge(:format => 'xml') 
    481481      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') 
    483483    end 
    484484