Skip to content
This repository
Browse code

uses PATCH for the forms of persisted records, and routes PATCH and P…

…UT to the update action of resources
  • Loading branch information...
commit b7a094536de6fdeb428aa79d21f1e2128169f45e 1 parent 31ceb5e
Xavier Noria authored February 24, 2012
4  actionpack/CHANGELOG.md
Source Rendered
... ...
@@ -1,5 +1,9 @@
1 1
 ## Rails 4.0.0 (unreleased) ##
2 2
 
  3
+* Forms of persisted records use always PATCH (via the `_method` hack). *fxn*
  4
+
  5
+* For resources, both PATCH and PUT are routed to the `update` action. *fxn*
  6
+
3 7
 *   Don't ignore `force_ssl` in development. This is a change of behavior - use a `:if` condition to recreate the old behavior.
4 8
 
5 9
         class AccountsController < ApplicationController
1  actionpack/lib/action_dispatch/railtie.rb
@@ -23,7 +23,6 @@ class Railtie < Rails::Railtie
23 23
       ActionDispatch::Http::URL.tld_length = app.config.action_dispatch.tld_length
24 24
       ActionDispatch::Request.ignore_accept_header = app.config.action_dispatch.ignore_accept_header
25 25
       ActionDispatch::Response.default_charset = app.config.action_dispatch.default_charset || app.config.encoding
26  
-      ActionDispatch::Routing::Mapper.default_method_for_update = app.config.default_method_for_update
27 26
 
28 27
       ActionDispatch::ExceptionWrapper.rescue_responses.merge!(config.action_dispatch.rescue_responses)
29 28
       ActionDispatch::ExceptionWrapper.rescue_templates.merge!(config.action_dispatch.rescue_templates)
17  actionpack/lib/action_dispatch/routing/mapper.rb
@@ -7,8 +7,6 @@
7 7
 module ActionDispatch
8 8
   module Routing
9 9
     class Mapper
10  
-      cattr_accessor(:default_method_for_update) {:put}
11  
-
12 10
       class Constraints #:nodoc:
13 11
         def self.new(app, constraints, request = Rack::Request)
14 12
           if constraints.any?
@@ -1012,10 +1010,11 @@ def resource(*resources, &block)
1012 1010
             end if parent_resource.actions.include?(:new)
1013 1011
 
1014 1012
             member do
1015  
-              get    :edit if parent_resource.actions.include?(:edit)
1016  
-              get    :show if parent_resource.actions.include?(:show)
  1013
+              get :edit if parent_resource.actions.include?(:edit)
  1014
+              get :show if parent_resource.actions.include?(:show)
1017 1015
               if parent_resource.actions.include?(:update)
1018  
-                send default_method_for_update, :update
  1016
+                patch :update
  1017
+                put   :update
1019 1018
               end
1020 1019
               delete :destroy if parent_resource.actions.include?(:destroy)
1021 1020
             end
@@ -1152,12 +1151,12 @@ def resources(*resources, &block)
1152 1151
               get :new
1153 1152
             end if parent_resource.actions.include?(:new)
1154 1153
 
1155  
-            # TODO: Only accept patch or put depending on config
1156 1154
             member do
1157  
-              get    :edit if parent_resource.actions.include?(:edit)
1158  
-              get    :show if parent_resource.actions.include?(:show)
  1155
+              get :edit if parent_resource.actions.include?(:edit)
  1156
+              get :show if parent_resource.actions.include?(:show)
1159 1157
               if parent_resource.actions.include?(:update)
1160  
-                send default_method_for_update, :update
  1158
+                patch :update
  1159
+                put   :update
1161 1160
               end
1162 1161
               delete :destroy if parent_resource.actions.include?(:destroy)
1163 1162
             end
2  actionpack/lib/action_view/base.rb
@@ -132,8 +132,6 @@ module ActionView #:nodoc:
132 132
   class Base
133 133
     include Helpers, ::ERB::Util, Context
134 134
 
135  
-    cattr_accessor(:default_method_for_update) {:put}
136  
-
137 135
     # Specify the proc used to decorate input tags that refer to attributes with errors.
138 136
     cattr_accessor :field_error_proc
139 137
     @@field_error_proc = Proc.new{ |html_tag, instance| "<div class=\"field_with_errors\">#{html_tag}</div>".html_safe }
2  actionpack/lib/action_view/helpers/form_helper.rb
@@ -385,7 +385,7 @@ def apply_form_for_options!(record, object, options) #:nodoc:
385 385
         object = convert_to_model(object)
386 386
 
387 387
         as = options[:as]
388  
-        action, method = object.respond_to?(:persisted?) && object.persisted? ? [:edit, ActionView::Base.default_method_for_update] : [:new, :post]
  388
+        action, method = object.respond_to?(:persisted?) && object.persisted? ? [:edit, :patch] : [:new, :post]
389 389
         options[:html].reverse_merge!(
390 390
           :class  => as ? "#{action}_#{as}" : dom_class(object, action),
391 391
           :id     => as ? "#{action}_#{as}" : [options[:namespace], dom_id(object, action)].compact.join("_").presence,
1  actionpack/lib/action_view/railtie.rb
@@ -34,7 +34,6 @@ class Railtie < Rails::Railtie
34 34
 
35 35
     initializer "action_view.set_configs" do |app|
36 36
       ActiveSupport.on_load(:action_view) do
37  
-        self.default_method_for_update = app.config.default_method_for_update
38 37
         app.config.action_view.each do |k,v|
39 38
           send "#{k}=", v
40 39
         end
8  actionpack/test/dispatch/routing_test.rb
@@ -1026,6 +1026,10 @@ def test_resource_routes_only_create_update_destroy
1026 1026
     assert_equal 'pasts#destroy', @response.body
1027 1027
     assert_equal '/past', past_path
1028 1028
 
  1029
+    patch '/present'
  1030
+    assert_equal 'presents#update', @response.body
  1031
+    assert_equal '/present', present_path
  1032
+
1029 1033
     put '/present'
1030 1034
     assert_equal 'presents#update', @response.body
1031 1035
     assert_equal '/present', present_path
@@ -1044,6 +1048,10 @@ def test_resources_routes_only_create_update_destroy
1044 1048
     assert_equal 'relationships#destroy', @response.body
1045 1049
     assert_equal '/relationships/1', relationship_path(1)
1046 1050
 
  1051
+    patch '/friendships/1'
  1052
+    assert_equal 'friendships#update', @response.body
  1053
+    assert_equal '/friendships/1', friendship_path(1)
  1054
+
1047 1055
     put '/friendships/1'
1048 1056
     assert_equal 'friendships#update', @response.body
1049 1057
     assert_equal '/friendships/1', friendship_path(1)
135  actionpack/test/template/form_helper_test.rb
@@ -181,7 +181,7 @@ def test_label_with_locales_and_nested_attributes
181 181
       end
182 182
     end
183 183
 
184  
-    expected = whole_form("/posts/123", "create-post" , "edit_post", :method => "put") do
  184
+    expected = whole_form("/posts/123", "create-post" , "edit_post", :method => 'patch') do
185 185
       "<label for=\"post_comments_attributes_0_body\">Write body here</label>"
186 186
     end
187 187
 
@@ -198,7 +198,7 @@ def test_label_with_locales_fallback_and_nested_attributes
198 198
       end
199 199
     end
200 200
 
201  
-    expected = whole_form("/posts/123", "create-post" , "edit_post", :method => "put") do
  201
+    expected = whole_form("/posts/123", "create-post" , "edit_post", :method => 'patch') do
202 202
       "<label for=\"post_tags_attributes_0_value\">Tag</label>"
203 203
     end
204 204
 
@@ -758,7 +758,7 @@ def test_form_for
758 758
       concat f.button('Create post')
759 759
     end
760 760
 
761  
-    expected = whole_form("/posts/123", "create-post" , "edit_post", :method => "put") do
  761
+    expected = whole_form("/posts/123", "create-post" , "edit_post", :method => 'patch') do
762 762
       "<label for='post_title'>The Title</label>" +
763 763
       "<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />" +
764 764
       "<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" +
@@ -778,7 +778,7 @@ def test_form_for_with_file_field_generate_multipart
778 778
       concat f.file_field(:file)
779 779
     end
780 780
 
781  
-    expected = whole_form("/posts/123", "create-post" , "edit_post", :method => "put", :multipart => true) do
  781
+    expected = whole_form("/posts/123", "create-post" , "edit_post", :method => 'patch', :multipart => true) do
782 782
       "<input name='post[file]' type='file' id='post_file' />"
783 783
     end
784 784
 
@@ -794,7 +794,7 @@ def test_fields_for_with_file_field_generate_multipart
794 794
       }
795 795
     end
796 796
 
797  
-    expected = whole_form("/posts/123", "edit_post_123" , "edit_post", :method => "put", :multipart => true) do
  797
+    expected = whole_form("/posts/123", "edit_post_123" , "edit_post", :method => 'patch', :multipart => true) do
798 798
       "<input name='post[comment][file]' type='file' id='post_comment_file' />"
799 799
     end
800 800
 
@@ -807,7 +807,7 @@ def test_form_for_with_format
807 807
       concat f.label(:title)
808 808
     end
809 809
 
810  
-    expected = whole_form("/posts/123.json", "edit_post_123" , "edit_post", :method => "put") do
  810
+    expected = whole_form("/posts/123.json", "edit_post_123" , "edit_post", :method => 'patch') do
811 811
       "<label for='post_title'>Title</label>"
812 812
     end
813 813
 
@@ -820,7 +820,7 @@ def test_form_for_with_model_using_relative_model_naming
820 820
       concat f.submit('Edit post')
821 821
     end
822 822
 
823  
-    expected = whole_form("/posts/44", "edit_post_44" , "edit_post", :method => "put") do
  823
+    expected = whole_form("/posts/44", "edit_post_44" , "edit_post", :method => 'patch') do
824 824
       "<input name='post[title]' size='30' type='text' id='post_title' value='And his name will be forty and four.' />" +
825 825
       "<input name='commit' type='submit' value='Edit post' />"
826 826
     end
@@ -837,7 +837,7 @@ def test_form_for_with_symbol_object_name
837 837
       concat f.submit('Create post')
838 838
     end
839 839
 
840  
-    expected =  whole_form("/posts/123", "create-post", "edit_other_name", :method => "put") do
  840
+    expected =  whole_form("/posts/123", "create-post", "edit_other_name", :method => 'patch') do
841 841
       "<label for='other_name_title' class='post_title'>Title</label>" +
842 842
       "<input name='other_name[title]' size='30' id='other_name_title' value='Hello World' type='text' />" +
843 843
       "<textarea name='other_name[body]' id='other_name_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" +
@@ -898,13 +898,13 @@ def test_form_for_with_search_field
898 898
   end
899 899
 
900 900
   def test_form_for_with_remote
901  
-    form_for(@post, :url => '/', :remote => true, :html => { :id => 'create-post', :method => :put }) do |f|
  901
+    form_for(@post, :url => '/', :remote => true, :html => { :id => 'create-post', :method => :patch}) do |f|
902 902
       concat f.text_field(:title)
903 903
       concat f.text_area(:body)
904 904
       concat f.check_box(:secret)
905 905
     end
906 906
 
907  
-    expected =  whole_form("/", "create-post", "edit_post", :method => "put", :remote => true) do
  907
+    expected =  whole_form("/", "create-post", "edit_post", :method => 'patch', :remote => true) do
908 908
       "<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />" +
909 909
       "<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" +
910 910
       "<input name='post[secret]' type='hidden' value='0' />" +
@@ -915,13 +915,13 @@ def test_form_for_with_remote
915 915
   end
916 916
 
917 917
   def test_form_for_with_remote_in_html
918  
-    form_for(@post, :url => '/', :html => { :remote => true, :id => 'create-post', :method => :put }) do |f|
  918
+    form_for(@post, :url => '/', :html => { :remote => true, :id => 'create-post', :method => :patch }) do |f|
919 919
       concat f.text_field(:title)
920 920
       concat f.text_area(:body)
921 921
       concat f.check_box(:secret)
922 922
     end
923 923
 
924  
-    expected =  whole_form("/", "create-post", "edit_post", :method => "put", :remote => true) do
  924
+    expected =  whole_form("/", "create-post", "edit_post", :method => 'patch', :remote => true) do
925 925
       "<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />" +
926 926
       "<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" +
927 927
       "<input name='post[secret]' type='hidden' value='0' />" +
@@ -975,7 +975,7 @@ def test_form_for_with_index
975 975
       concat f.check_box(:secret)
976 976
     end
977 977
 
978  
-    expected = whole_form('/posts/123', 'edit_post[]', 'edit_post[]', 'put') do
  978
+    expected = whole_form('/posts/123', 'edit_post[]', 'edit_post[]', 'patch') do
979 979
       "<label for='post_123_title'>Title</label>" +
980 980
       "<input name='post[123][title]' size='30' type='text' id='post_123_title' value='Hello World' />" +
981 981
       "<textarea name='post[123][body]' id='post_123_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" +
@@ -993,7 +993,7 @@ def test_form_for_with_nil_index_option_override
993 993
       concat f.check_box(:secret)
994 994
     end
995 995
 
996  
-    expected = whole_form('/posts/123', 'edit_post[]', 'edit_post[]', 'put') do
  996
+    expected = whole_form('/posts/123', 'edit_post[]', 'edit_post[]', 'patch') do
997 997
       "<input name='post[][title]' size='30' type='text' id='post__title' value='Hello World' />" +
998 998
       "<textarea name='post[][body]' id='post__body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" +
999 999
       "<input name='post[][secret]' type='hidden' value='0' />" +
@@ -1010,7 +1010,7 @@ def test_form_for_with_namespace
1010 1010
       concat f.check_box(:secret)
1011 1011
     end
1012 1012
 
1013  
-    expected = whole_form('/posts/123', 'namespace_edit_post_123', 'edit_post', 'put') do
  1013
+    expected = whole_form('/posts/123', 'namespace_edit_post_123', 'edit_post', 'patch') do
1014 1014
       "<input name='post[title]' size='30' type='text' id='namespace_post_title' value='Hello World' />" +
1015 1015
       "<textarea name='post[body]' id='namespace_post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" +
1016 1016
       "<input name='post[secret]' type='hidden' value='0' />" +
@@ -1026,7 +1026,7 @@ def test_form_for_with_namespace_with_label
1026 1026
       concat f.text_field(:title)
1027 1027
     end
1028 1028
 
1029  
-    expected = whole_form('/posts/123', 'namespace_edit_post_123', 'edit_post', 'put') do
  1029
+    expected = whole_form('/posts/123', 'namespace_edit_post_123', 'edit_post', 'patch') do
1030 1030
       "<label for='namespace_post_title'>Title</label>" +
1031 1031
       "<input name='post[title]' size='30' type='text' id='namespace_post_title' value='Hello World' />"
1032 1032
     end
@@ -1040,7 +1040,7 @@ def test_two_form_for_with_namespace
1040 1040
       concat f.text_field(:title)
1041 1041
     end
1042 1042
 
1043  
-    expected_1 = whole_form('/posts/123', 'namespace_1_edit_post_123', 'edit_post', 'put') do
  1043
+    expected_1 = whole_form('/posts/123', 'namespace_1_edit_post_123', 'edit_post', 'patch') do
1044 1044
       "<label for='namespace_1_post_title'>Title</label>" +
1045 1045
       "<input name='post[title]' size='30' type='text' id='namespace_1_post_title' value='Hello World' />"
1046 1046
     end
@@ -1052,7 +1052,7 @@ def test_two_form_for_with_namespace
1052 1052
       concat f.text_field(:title)
1053 1053
     end
1054 1054
 
1055  
-    expected_2 = whole_form('/posts/123', 'namespace_2_edit_post_123', 'edit_post', 'put') do
  1055
+    expected_2 = whole_form('/posts/123', 'namespace_2_edit_post_123', 'edit_post', 'patch') do
1056 1056
       "<label for='namespace_2_post_title'>Title</label>" +
1057 1057
       "<input name='post[title]' size='30' type='text' id='namespace_2_post_title' value='Hello World' />"
1058 1058
     end
@@ -1070,7 +1070,7 @@ def test_fields_for_with_namespace
1070 1070
       }
1071 1071
     end
1072 1072
 
1073  
-    expected = whole_form('/posts/123', 'namespace_edit_post_123', 'edit_post', 'put') do
  1073
+    expected = whole_form('/posts/123', 'namespace_edit_post_123', 'edit_post', 'patch') do
1074 1074
       "<input name='post[title]' size='30' type='text' id='namespace_post_title' value='Hello World' />" +
1075 1075
       "<textarea name='post[body]' id='namespace_post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" +
1076 1076
       "<input name='post[comment][body]' size='30' type='text' id='namespace_post_comment_body' value='Hello World' />"
@@ -1104,7 +1104,7 @@ def test_submit_with_object_as_existing_record_and_locale_strings
1104 1104
       concat f.submit
1105 1105
     end
1106 1106
 
1107  
-    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'put') do
  1107
+    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'patch') do
1108 1108
       "<input name='commit' type='submit' value='Confirm Post changes' />"
1109 1109
     end
1110 1110
 
@@ -1136,7 +1136,7 @@ def test_submit_with_object_and_nested_lookup
1136 1136
       concat f.submit
1137 1137
     end
1138 1138
 
1139  
-    expected = whole_form('/posts/123', 'edit_another_post', 'edit_another_post', :method => 'put') do
  1139
+    expected = whole_form('/posts/123', 'edit_another_post', 'edit_another_post', :method => 'patch') do
1140 1140
       "<input name='commit' type='submit' value='Update your Post' />"
1141 1141
     end
1142 1142
 
@@ -1153,7 +1153,7 @@ def test_nested_fields_for
1153 1153
       }
1154 1154
     end
1155 1155
 
1156  
-    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'put') do
  1156
+    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'patch') do
1157 1157
       "<input name='post[comment][body]' size='30' type='text' id='post_comment_body' value='Hello World' />"
1158 1158
     end
1159 1159
 
@@ -1168,7 +1168,7 @@ def test_nested_fields_for_with_nested_collections
1168 1168
       }
1169 1169
     end
1170 1170
 
1171  
-    expected = whole_form('/posts/123', 'edit_post[]', 'edit_post[]', 'put') do
  1171
+    expected = whole_form('/posts/123', 'edit_post[]', 'edit_post[]', 'patch') do
1172 1172
       "<input name='post[123][title]' size='30' type='text' id='post_123_title' value='Hello World' />" +
1173 1173
       "<input name='post[123][comment][][name]' size='30' type='text' id='post_123_comment__name' value='new comment' />"
1174 1174
     end
@@ -1184,7 +1184,7 @@ def test_nested_fields_for_with_index_and_parent_fields
1184 1184
       }
1185 1185
     end
1186 1186
 
1187  
-    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', 'put') do
  1187
+    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', 'patch') do
1188 1188
       "<input name='post[1][title]' size='30' type='text' id='post_1_title' value='Hello World' />" +
1189 1189
       "<input name='post[1][comment][1][name]' size='30' type='text' id='post_1_comment_1_name' value='new comment' />"
1190 1190
     end
@@ -1199,7 +1199,7 @@ def test_form_for_with_index_and_nested_fields_for
1199 1199
       }
1200 1200
     end
1201 1201
 
1202  
-    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', 'put') do
  1202
+    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', 'patch') do
1203 1203
       "<input name='post[1][comment][title]' size='30' type='text' id='post_1_comment_title' value='Hello World' />"
1204 1204
     end
1205 1205
 
@@ -1213,7 +1213,7 @@ def test_nested_fields_for_with_index_on_both
1213 1213
       }
1214 1214
     end
1215 1215
 
1216  
-    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', 'put') do
  1216
+    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', 'patch') do
1217 1217
       "<input name='post[1][comment][5][title]' size='30' type='text' id='post_1_comment_5_title' value='Hello World' />"
1218 1218
     end
1219 1219
 
@@ -1227,7 +1227,7 @@ def test_nested_fields_for_with_auto_index
1227 1227
       }
1228 1228
     end
1229 1229
 
1230  
-    expected = whole_form('/posts/123', 'edit_post[]', 'edit_post[]', 'put') do
  1230
+    expected = whole_form('/posts/123', 'edit_post[]', 'edit_post[]', 'patch') do
1231 1231
       "<input name='post[123][comment][title]' size='30' type='text' id='post_123_comment_title' value='Hello World' />"
1232 1232
     end
1233 1233
 
@@ -1241,7 +1241,7 @@ def test_nested_fields_for_with_index_radio_button
1241 1241
       }
1242 1242
     end
1243 1243
 
1244  
-    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', 'put') do
  1244
+    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', 'patch') do
1245 1245
       "<input name='post[comment][5][title]' type='radio' id='post_comment_5_title_hello' value='hello' />"
1246 1246
     end
1247 1247
 
@@ -1255,7 +1255,7 @@ def test_nested_fields_for_with_auto_index_on_both
1255 1255
       }
1256 1256
     end
1257 1257
 
1258  
-    expected = whole_form('/posts/123', 'edit_post[]', 'edit_post[]', 'put') do
  1258
+    expected = whole_form('/posts/123', 'edit_post[]', 'edit_post[]', 'patch') do
1259 1259
       "<input name='post[123][comment][123][title]' size='30' type='text' id='post_123_comment_123_title' value='Hello World' />"
1260 1260
     end
1261 1261
 
@@ -1275,9 +1275,9 @@ def test_nested_fields_for_with_index_and_auto_index
1275 1275
       }
1276 1276
     end
1277 1277
 
1278  
-    expected = whole_form('/posts/123', 'edit_post[]', 'edit_post[]', 'put') do
  1278
+    expected = whole_form('/posts/123', 'edit_post[]', 'edit_post[]', 'patch') do
1279 1279
       "<input name='post[123][comment][5][title]' size='30' type='text' id='post_123_comment_5_title' value='Hello World' />"
1280  
-    end + whole_form('/posts/123', 'edit_post', 'edit_post', 'put') do
  1280
+    end + whole_form('/posts/123', 'edit_post', 'edit_post', 'patch') do
1281 1281
       "<input name='post[1][comment][123][title]' size='30' type='text' id='post_1_comment_123_title' value='Hello World' />"
1282 1282
     end
1283 1283
 
@@ -1294,7 +1294,7 @@ def test_nested_fields_for_with_a_new_record_on_a_nested_attributes_one_to_one_a
1294 1294
       }
1295 1295
     end
1296 1296
 
1297  
-    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'put') do
  1297
+    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'patch') do
1298 1298
       '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' +
1299 1299
         '<input id="post_author_attributes_name" name="post[author_attributes][name]" size="30" type="text" value="new author" />'
1300 1300
     end
@@ -1321,7 +1321,7 @@ def test_nested_fields_for_with_an_existing_record_on_a_nested_attributes_one_to
1321 1321
       }
1322 1322
     end
1323 1323
 
1324  
-   expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'put') do
  1324
+   expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'patch') do
1325 1325
      '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' +
1326 1326
      '<input id="post_author_attributes_name" name="post[author_attributes][name]" size="30" type="text" value="author #321" />' +
1327 1327
      '<input id="post_author_attributes_id" name="post[author_attributes][id]" type="hidden" value="321" />'
@@ -1340,7 +1340,7 @@ def test_nested_fields_for_with_an_existing_record_on_a_nested_attributes_one_to
1340 1340
       }
1341 1341
     end
1342 1342
 
1343  
-    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'put') do
  1343
+    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'patch') do
1344 1344
       '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' +
1345 1345
       '<input id="post_author_attributes_name" name="post[author_attributes][name]" size="30" type="text" value="author #321" />' +
1346 1346
       '<input id="post_author_attributes_id" name="post[author_attributes][id]" type="hidden" value="321" />'
@@ -1359,7 +1359,7 @@ def test_nested_fields_for_with_an_existing_record_on_a_nested_attributes_one_to
1359 1359
       }
1360 1360
     end
1361 1361
 
1362  
-    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'put') do
  1362
+    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'patch') do
1363 1363
       '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' +
1364 1364
       '<input id="post_author_attributes_name" name="post[author_attributes][name]" size="30" type="text" value="author #321" />'
1365 1365
     end
@@ -1377,7 +1377,7 @@ def test_nested_fields_for_with_an_existing_record_on_a_nested_attributes_one_to
1377 1377
       }
1378 1378
     end
1379 1379
 
1380  
-    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'put') do
  1380
+    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'patch') do
1381 1381
       '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' +
1382 1382
       '<input id="post_author_attributes_name" name="post[author_attributes][name]" size="30" type="text" value="author #321" />'
1383 1383
     end
@@ -1395,7 +1395,7 @@ def test_nested_fields_for_with_an_existing_record_on_a_nested_attributes_one_to
1395 1395
       }
1396 1396
     end
1397 1397
 
1398  
-    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'put') do
  1398
+    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'patch') do
1399 1399
       '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' +
1400 1400
       '<input id="post_author_attributes_name" name="post[author_attributes][name]" size="30" type="text" value="author #321" />' +
1401 1401
       '<input id="post_author_attributes_id" name="post[author_attributes][id]" type="hidden" value="321" />'
@@ -1415,7 +1415,7 @@ def test_nested_fields_for_with_existing_records_on_a_nested_attributes_one_to_o
1415 1415
       }
1416 1416
     end
1417 1417
 
1418  
-    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'put') do
  1418
+    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'patch') do
1419 1419
       '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' +
1420 1420
       '<input id="post_author_attributes_id" name="post[author_attributes][id]" type="hidden" value="321" />' +
1421 1421
       '<input id="post_author_attributes_name" name="post[author_attributes][name]" size="30" type="text" value="author #321" />'
@@ -1436,7 +1436,7 @@ def test_nested_fields_for_with_existing_records_on_a_nested_attributes_collecti
1436 1436
       end
1437 1437
     end
1438 1438
 
1439  
-    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'put') do
  1439
+    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'patch') do
1440 1440
       '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' +
1441 1441
       '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" size="30" type="text" value="comment #1" />' +
1442 1442
       '<input id="post_comments_attributes_0_id" name="post[comments_attributes][0][id]" type="hidden" value="1" />' +
@@ -1463,7 +1463,7 @@ def test_nested_fields_for_with_existing_records_on_a_nested_attributes_collecti
1463 1463
       end
1464 1464
     end
1465 1465
 
1466  
-    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'put') do
  1466
+    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'patch') do
1467 1467
       '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' +
1468 1468
       '<input id="post_author_attributes_name" name="post[author_attributes][name]" size="30" type="text" value="author #321" />' +
1469 1469
       '<input id="post_author_attributes_id" name="post[author_attributes][id]" type="hidden" value="321" />' +
@@ -1490,7 +1490,7 @@ def test_nested_fields_for_with_existing_records_on_a_nested_attributes_collecti
1490 1490
       end
1491 1491
     end
1492 1492
 
1493  
-    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'put') do
  1493
+    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'patch') do
1494 1494
       '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' +
1495 1495
       '<input id="post_author_attributes_name" name="post[author_attributes][name]" size="30" type="text" value="author #321" />' +
1496 1496
       '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" size="30" type="text" value="comment #1" />' +
@@ -1516,7 +1516,7 @@ def test_nested_fields_for_with_existing_records_on_a_nested_attributes_collecti
1516 1516
       end
1517 1517
     end
1518 1518
 
1519  
-    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'put') do
  1519
+    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'patch') do
1520 1520
       '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' +
1521 1521
       '<input id="post_author_attributes_name" name="post[author_attributes][name]" size="30" type="text" value="author #321" />' +
1522 1522
       '<input id="post_author_attributes_id" name="post[author_attributes][id]" type="hidden" value="321" />' +
@@ -1539,7 +1539,7 @@ def test_nested_fields_for_with_existing_records_on_a_nested_attributes_collecti
1539 1539
       end
1540 1540
     end
1541 1541
 
1542  
-    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'put') do
  1542
+    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'patch') do
1543 1543
       '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' +
1544 1544
       '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" size="30" type="text" value="comment #1" />' +
1545 1545
       '<input id="post_comments_attributes_0_id" name="post[comments_attributes][0][id]" type="hidden" value="1" />' +
@@ -1563,7 +1563,7 @@ def test_nested_fields_for_with_existing_records_on_a_nested_attributes_collecti
1563 1563
       end
1564 1564
     end
1565 1565
 
1566  
-    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'put') do
  1566
+    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'patch') do
1567 1567
       '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' +
1568 1568
       '<input id="post_comments_attributes_0_id" name="post[comments_attributes][0][id]" type="hidden" value="1" />' +
1569 1569
       '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" size="30" type="text" value="comment #1" />' +
@@ -1586,7 +1586,7 @@ def test_nested_fields_for_with_new_records_on_a_nested_attributes_collection_as
1586 1586
       end
1587 1587
     end
1588 1588
 
1589  
-    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'put') do
  1589
+    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'patch') do
1590 1590
       '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' +
1591 1591
       '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" size="30" type="text" value="new comment" />' +
1592 1592
       '<input id="post_comments_attributes_1_name" name="post[comments_attributes][1][name]" size="30" type="text" value="new comment" />'
@@ -1607,7 +1607,7 @@ def test_nested_fields_for_with_existing_and_new_records_on_a_nested_attributes_
1607 1607
       end
1608 1608
     end
1609 1609
 
1610  
-    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'put') do
  1610
+    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'patch') do
1611 1611
       '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' +
1612 1612
       '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" size="30" type="text" value="comment #321" />' +
1613 1613
       '<input id="post_comments_attributes_0_id" name="post[comments_attributes][0][id]" type="hidden" value="321" />' +
@@ -1625,7 +1625,7 @@ def test_nested_fields_for_with_an_empty_supplied_attributes_collection
1625 1625
       end
1626 1626
     end
1627 1627
 
1628  
-    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'put') do
  1628
+    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'patch') do
1629 1629
       '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />'
1630 1630
     end
1631 1631
 
@@ -1642,7 +1642,7 @@ def test_nested_fields_for_with_existing_records_on_a_supplied_nested_attributes
1642 1642
       }
1643 1643
     end
1644 1644
 
1645  
-    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'put') do
  1645
+    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'patch') do
1646 1646
       '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' +
1647 1647
       '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" size="30" type="text" value="comment #1" />' +
1648 1648
       '<input id="post_comments_attributes_0_id" name="post[comments_attributes][0][id]" type="hidden" value="1" />' +
@@ -1663,7 +1663,7 @@ def test_nested_fields_for_arel_like
1663 1663
       }
1664 1664
     end
1665 1665
 
1666  
-    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'put') do
  1666
+    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'patch') do
1667 1667
       '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' +
1668 1668
       '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" size="30" type="text" value="comment #1" />' +
1669 1669
       '<input id="post_comments_attributes_0_id" name="post[comments_attributes][0][id]" type="hidden" value="1" />' +
@@ -1685,7 +1685,7 @@ def test_nested_fields_for_with_existing_records_on_a_supplied_nested_attributes
1685 1685
       }
1686 1686
     end
1687 1687
 
1688  
-    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'put') do
  1688
+    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'patch') do
1689 1689
       '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' +
1690 1690
       '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" size="30" type="text" value="comment #1" />' +
1691 1691
       '<input id="post_comments_attributes_0_id" name="post[comments_attributes][0][id]" type="hidden" value="1" />' +
@@ -1708,7 +1708,7 @@ def test_nested_fields_for_on_a_nested_attributes_collection_association_yields_
1708 1708
       }
1709 1709
     end
1710 1710
 
1711  
-    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'put') do
  1711
+    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'patch') do
1712 1712
       '<input name="post[title]" size="30" type="text" id="post_title" value="Hello World" />' +
1713 1713
       '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" size="30" type="text" value="comment #321" />' +
1714 1714
       '<input id="post_comments_attributes_0_id" name="post[comments_attributes][0][id]" type="hidden" value="321" />' +
@@ -1728,7 +1728,7 @@ def test_nested_fields_for_with_child_index_option_override_on_a_nested_attribut
1728 1728
       }
1729 1729
     end
1730 1730
 
1731  
-    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'put') do
  1731
+    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'patch') do
1732 1732
       '<input id="post_comments_attributes_abc_name" name="post[comments_attributes][abc][name]" size="30" type="text" value="comment #321" />' +
1733 1733
       '<input id="post_comments_attributes_abc_id" name="post[comments_attributes][abc][id]" type="hidden" value="321" />'
1734 1734
     end
@@ -1764,7 +1764,7 @@ def test_nested_fields_uses_unique_indices_for_different_collection_associations
1764 1764
       }
1765 1765
     end
1766 1766
 
1767  
-    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'put') do
  1767
+    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'patch') do
1768 1768
       '<input id="post_comments_attributes_0_name" name="post[comments_attributes][0][name]" size="30" type="text" value="comment #321" />' +
1769 1769
       '<input id="post_comments_attributes_0_relevances_attributes_0_value" name="post[comments_attributes][0][relevances_attributes][0][value]" size="30" type="text" value="commentrelevance #314" />' +
1770 1770
       '<input id="post_comments_attributes_0_relevances_attributes_0_id" name="post[comments_attributes][0][relevances_attributes][0][id]" type="hidden" value="314" />' +
@@ -1791,7 +1791,7 @@ def test_nested_fields_for_with_hash_like_model
1791 1791
       }
1792 1792
     end
1793 1793
 
1794  
-    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'put') do
  1794
+    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'patch') do
1795 1795
       '<input id="post_author_attributes_name" name="post[author_attributes][name]" size="30" type="text" value="hash backed author" />'
1796 1796
     end
1797 1797
 
@@ -1930,7 +1930,7 @@ def test_form_for_and_fields_for
1930 1930
       }
1931 1931
     end
1932 1932
 
1933  
-    expected = whole_form('/posts/123', 'create-post', 'edit_post', :method => 'put') do
  1933
+    expected = whole_form('/posts/123', 'create-post', 'edit_post', :method => 'patch') do
1934 1934
       "<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />" +
1935 1935
       "<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" +
1936 1936
       "<input name='parent_post[secret]' type='hidden' value='0' />" +
@@ -1950,7 +1950,7 @@ def test_form_for_and_fields_for_with_object
1950 1950
       }
1951 1951
     end
1952 1952
 
1953  
-    expected = whole_form('/posts/123', 'create-post', 'edit_post', :method => 'put') do
  1953
+    expected = whole_form('/posts/123', 'create-post', 'edit_post', :method => 'patch') do
1954 1954
       "<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />" +
1955 1955
       "<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" +
1956 1956
       "<input name='post[comment][name]' type='text' id='post_comment_name' value='new comment' size='30' />"
@@ -1966,7 +1966,7 @@ def test_form_for_and_fields_for_with_non_nested_association_and_without_object
1966 1966
       }
1967 1967
     end
1968 1968
 
1969  
-    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', 'put') do
  1969
+    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', 'patch') do
1970 1970
       "<input name='post[category][name]' type='text' size='30' id='post_category_name' />"
1971 1971
     end
1972 1972
 
@@ -1990,7 +1990,7 @@ def test_form_for_with_labelled_builder
1990 1990
       concat f.check_box(:secret)
1991 1991
     end
1992 1992
 
1993  
-    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'put') do
  1993
+    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'patch') do
1994 1994
       "<label for='title'>Title:</label> <input name='post[title]' size='30' type='text' id='post_title' value='Hello World' /><br/>" +
1995 1995
       "<label for='body'>Body:</label> <textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea><br/>" +
1996 1996
       "<label for='secret'>Secret:</label> <input name='post[secret]' type='hidden' value='0' /><input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' /><br/>"
@@ -2040,7 +2040,7 @@ def test_default_form_builder
2040 2040
       concat f.check_box(:secret)
2041 2041
     end
2042 2042
 
2043  
-    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'put') do
  2043
+    expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'patch') do
2044 2044
       "<label for='title'>Title:</label> <input name='post[title]' size='30' type='text' id='post_title' value='Hello World' /><br/>" +
2045 2045
       "<label for='body'>Body:</label> <textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea><br/>" +
2046 2046
       "<label for='secret'>Secret:</label> <input name='post[secret]' type='hidden' value='0' /><input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' /><br/>"
@@ -2120,7 +2120,7 @@ def test_form_for_with_labelled_builder_with_nested_fields_for_with_custom_build
2120 2120
 
2121 2121
   def test_form_for_with_html_options_adds_options_to_form_tag
2122 2122
     form_for(@post, :html => {:id => 'some_form', :class => 'some_class'}) do |f| end
2123  
-    expected = whole_form("/posts/123", "some_form", "some_class", 'put')
  2123
+    expected = whole_form("/posts/123", "some_form", "some_class", 'patch')
2124 2124
 
2125 2125
     assert_dom_equal expected, output_buffer
2126 2126
   end
@@ -2128,7 +2128,7 @@ def test_form_for_with_html_options_adds_options_to_form_tag
2128 2128
   def test_form_for_with_string_url_option
2129 2129
     form_for(@post, :url => 'http://www.otherdomain.com') do |f| end
2130 2130
 
2131  
-    assert_equal whole_form("http://www.otherdomain.com", 'edit_post_123', 'edit_post', 'put'), output_buffer
  2131
+    assert_equal whole_form("http://www.otherdomain.com", 'edit_post_123', 'edit_post', 'patch'), output_buffer
2132 2132
   end
2133 2133
 
2134 2134
   def test_form_for_with_hash_url_option
@@ -2141,14 +2141,14 @@ def test_form_for_with_hash_url_option
2141 2141
   def test_form_for_with_record_url_option
2142 2142
     form_for(@post, :url => @post) do |f| end
2143 2143
 
2144  
-    expected = whole_form("/posts/123", 'edit_post_123', 'edit_post', 'put')
  2144
+    expected = whole_form("/posts/123", 'edit_post_123', 'edit_post', 'patch')
2145 2145
     assert_equal expected, output_buffer
2146 2146
   end
2147 2147
 
2148 2148
   def test_form_for_with_existing_object
2149 2149
     form_for(@post) do |f| end
2150 2150
 
2151  
-    expected = whole_form("/posts/123", "edit_post_123", "edit_post", "put")
  2151
+    expected = whole_form("/posts/123", "edit_post_123", "edit_post", 'patch')
2152 2152
     assert_equal expected, output_buffer
2153 2153
   end
2154 2154
 
@@ -2167,7 +2167,7 @@ def test_form_for_with_existing_object_in_list
2167 2167
     @comment.save
2168 2168
     form_for([@post, @comment]) {}
2169 2169
 
2170  
-    expected = whole_form(post_comment_path(@post, @comment), "edit_comment_1", "edit_comment", "put")
  2170
+    expected = whole_form(post_comment_path(@post, @comment), "edit_comment_1", "edit_comment", 'patch')
2171 2171
     assert_dom_equal expected, output_buffer
2172 2172
   end
2173 2173
 
@@ -2182,7 +2182,7 @@ def test_form_for_with_existing_object_and_namespace_in_list
2182 2182
     @comment.save
2183 2183
     form_for([:admin, @post, @comment]) {}
2184 2184
 
2185  
-    expected = whole_form(admin_post_comment_path(@post, @comment), "edit_comment_1", "edit_comment", "put")
  2185
+    expected = whole_form(admin_post_comment_path(@post, @comment), "edit_comment_1", "edit_comment", 'patch')
2186 2186
     assert_dom_equal expected, output_buffer
2187 2187
   end
2188 2188
 
@@ -2196,17 +2196,14 @@ def test_form_for_with_new_object_and_namespace_in_list
2196 2196
   def test_form_for_with_existing_object_and_custom_url
2197 2197
     form_for(@post, :url => "/super_posts") do |f| end
2198 2198
 
2199  
-    expected = whole_form("/super_posts", "edit_post_123", "edit_post", "put")
  2199
+    expected = whole_form("/super_posts", "edit_post_123", "edit_post", 'patch')
2200 2200
     assert_equal expected, output_buffer
2201 2201
   end
2202 2202
 
2203 2203
   def test_form_for_with_default_method_as_patch
2204  
-    ActionView::Base.default_method_for_update = :patch
2205 2204
     form_for(@post) {}
2206 2205
     expected = whole_form("/posts/123", "edit_post_123", "edit_post", "patch")
2207 2206
     assert_dom_equal expected, output_buffer
2208  
-  ensure
2209  
-    ActionView::Base.default_method_for_update = :put
2210 2207
   end
2211 2208
 
2212 2209
   def test_fields_for_returns_block_result
5  railties/CHANGELOG.md
Source Rendered
... ...
@@ -1,10 +1,5 @@
1 1
 ## Rails 4.0.0 (unreleased) ##
2 2
 
3  
-* New configuration option `config.default_method_for_update` tells Rails which
4  
-  HTTP verb to use for update actions. Values can be `:patch` and `:put`.
5  
-  Default is `:put` for backwards compatibility, but you are encouraged to
6  
-  use `:patch` for proper HTTP semantics with partial updates.
7  
-
8 3
 *   Allow to set class that will be used to run as a console, other than IRB, with `Rails.application.config.console=`. It's best to add it to `console` block. *Piotr Sarnacki*
9 4
 
10 5
     Example:
2  railties/guides/source/configuring.textile
Source Rendered
@@ -76,8 +76,6 @@ NOTE. The +config.asset_path+ configuration is ignored if the asset pipeline is
76 76
 
77 77
 * +config.consider_all_requests_local+ is a flag. If true then any error will cause detailed debugging information to be dumped in the HTTP response, and the +Rails::Info+ controller will show the application runtime context in +/rails/info/properties+. True by default in development and test environments, and false in production mode. For finer-grained control, set this to false and implement +local_request?+ in controllers to specify which requests should provide debugging information on errors.
78 78
 
79  
-* +config.default_method_for_update+ tells Rails which HTTP method to use for update actions by default. Set this to +:patch+ for proper HTTP update semantics. The default is +:put+ for backwards compatibility.
80  
-
81 79
 * +config.dependency_loading+ is a flag that allows you to disable constant autoloading setting it to false. It only has effect if +config.cache_classes+ is true, which it is by default in production mode. This flag is set to false by +config.threadsafe!+.
82 80
 
83 81
 * +config.eager_load_paths+ accepts an array of paths from which Rails will eager load on boot if cache classes is enabled. Defaults to every folder in the +app+ directory of the application.
7  railties/guides/source/form_helpers.textile
Source Rendered
@@ -292,7 +292,7 @@ form_for(@article)
292 292
 
293 293
 ## Editing an existing article
294 294
 # long-style:
295  
-form_for(@article, :url => article_path(@article), :html => { :method => "put" })
  295
+form_for(@article, :url => article_path(@article), :html => { :method => "patch" })
296 296
 # short-style:
297 297
 form_for(@article)
298 298
 </ruby>
@@ -303,11 +303,6 @@ Rails will also automatically set the +class+ and +id+ of the form appropriately
303 303
 
304 304
 WARNING: When you're using STI (single-table inheritance) with your models, you can't rely on record identification on a subclass if only their parent class is declared a resource. You will have to specify the model name, +:url+, and +:method+ explicitly.
305 305
 
306  
-NOTE: Rails can use the +PATCH+ method instead of +PUT+ for update forms if you set the following option in your +config/application.rb+:
307  
-<ruby>
308  
-config.default_method_for_update = :patch
309  
-</ruby>
310  
-
311 306
 h5. Dealing with Namespaces
312 307
 
313 308
 If you have created namespaced routes, +form_for+ has a nifty shorthand for that too. If your application has an admin namespace then
14  railties/guides/source/routing.textile
Source Rendered
@@ -85,7 +85,7 @@ creates seven different routes in your application, all mapping to the +Photos+
85 85
 |PUT/PATCH    |/photos/:id       |update   |update a specific photo                      |
86 86
 |DELETE       |/photos/:id       |destroy  |delete a specific photo                      |
87 87
 
88  
-NOTE: The HTTP Verb for the +update+ action defaults to +PUT+ for backwards compatibility. Set +config.default_method_for_update+ to +:patch+ to use +PATCH+. Rails routes are matched in the order they are specified, so if you have a +resources :photos+ above a +get 'photos/poll'+ the +show+ action's route for the +resources+ line will be matched before the +get+ line. To fix this, move the +get+ line *above* the +resources+ line so that it is matched first.
  88
+NOTE: Rails routes are matched in the order they are specified, so if you have a +resources :photos+ above a +get 'photos/poll'+ the +show+ action's route for the +resources+ line will be matched before the +get+ line. To fix this, move the +get+ line *above* the +resources+ line so that it is matched first.
89 89
 
90 90
 h4. Paths and URLs
91 91
 
@@ -140,7 +140,7 @@ creates six different routes in your application, all mapping to the +Geocoders+
140 140
 |PUT/PATCH   |/geocoder      |update   |update the one and only geocoder resource     |
141 141
 |DELETE      |/geocoder      |destroy  |delete the geocoder resource                  |
142 142
 
143  
-NOTE: The HTTP Verb for the +update+ action defaults to +PUT+ for backwards compatibility. Set +config.default_method_for_update+ to +:patch+ to use +PATCH+. Because you might want to use the same controller for a singular route (+/account+) and a plural route (+/accounts/45+), singular resources map to plural controllers.
  143
+NOTE: Because you might want to use the same controller for a singular route (+/account+) and a plural route (+/accounts/45+), singular resources map to plural controllers.
144 144
 
145 145
 A singular resourceful route generates these helpers:
146 146
 
@@ -171,8 +171,6 @@ This will create a number of routes for each of the +posts+ and +comments+ contr
171 171
 |PUT/PATCH   |/admin/posts/:id      |update   | admin_post_path(:id)      |
172 172
 |DELETE      |/admin/posts/:id      |destroy  | admin_post_path(:id)      |
173 173
 
174  
-NOTE: The HTTP Verb for the +update+ action defaults to +PUT+ for backwards compatibility. Set +config.default_method_for_update+ to +:patch+ to use +PATCH+.
175  
-
176 174
 If you want to route +/posts+ (without the prefix +/admin+) to +Admin::PostsController+, you could use
177 175
 
178 176
 <ruby>
@@ -212,8 +210,6 @@ In each of these cases, the named routes remain the same as if you did not use +
212 210
 |PUT/PATCH   |/admin/posts/:id     |update   | post_path(:id)     |
213 211
 |DELETE      |/admin/posts/:id     |destroy  | post_path(:id)     |
214 212
 
215  
-NOTE: The HTTP Verb for the +update+ action defaults to +PUT+ for backwards compatibility. Set +config.default_method_for_update+ to +:patch+ to use +PATCH+.
216  
-
217 213
 h4. Nested Resources
218 214
 
219 215
 It's common to have resources that are logically children of other resources. For example, suppose your application includes these models:
@@ -247,8 +243,6 @@ In addition to the routes for magazines, this declaration will also route ads to
247 243
 |PUT/PATCH   |/magazines/:id/ads/:id      |update   |update a specific ad belonging to a specific magazine                      |
248 244
 |DELETE      |/magazines/:id/ads/:id      |destroy  |delete a specific ad belonging to a specific magazine                      |
249 245
 
250  
-NOTE: The HTTP Verb for the +update+ action defaults to +PUT+ for backwards compatibility. Set +config.default_method_for_update+ to +:patch+ to use +PATCH+.
251  
-
252 246
 This will also create routing helpers such as +magazine_ads_url+ and +edit_magazine_ad_path+. These helpers take an instance of Magazine as the first parameter (+magazine_ads_url(@magazine)+).
253 247
 
254 248
 h5. Limits to Nesting
@@ -693,8 +687,6 @@ will recognize incoming paths beginning with +/photos+ and route the requests to
693 687
 |PUT/PATCH  |/photos/:id       |update   | image_path(:id)      |
694 688
 |DELETE     |/photos/:id       |destroy  | image_path(:id)      |
695 689
 
696  
-NOTE: The HTTP Verb for the +update+ action defaults to +PUT+ for backwards compatibility. Set +config.default_method_for_update+ to +:patch+ to use +PATCH+.
697  
-
698 690
 h4. Overriding the +new+ and +edit+ Segments
699 691
 
700 692
 The +:path_names+ option lets you override the automatically-generated "new" and "edit" segments in paths:
@@ -799,8 +791,6 @@ Rails now creates routes to the +CategoriesController+.
799 791
 |PUT/PATCH  |/kategorien/:id            |update   | category_path(:id)      |
800 792
 |DELETE     |/kategorien/:id            |destroy  | category_path(:id)      |
801 793
 
802  
-NOTE: The HTTP Verb for the +update+ action defaults to +PUT+ for backwards compatibility. Set +config.default_method_for_update+ to +:patch+ to use +PATCH+.
803  
-
804 794
 h4. Overriding the Singular Form
805 795
 
806 796
 If you want to define the singular form of a resource, you should add additional rules to the +Inflector+.
3  railties/lib/rails/application/configuration.rb
@@ -11,7 +11,7 @@ class Configuration < ::Rails::Engine::Configuration
11 11
                     :force_ssl, :helpers_paths, :logger, :log_tags, :preload_frameworks,
12 12
                     :railties_order, :relative_url_root, :secret_token,
13 13
                     :serve_static_assets, :ssl_options, :static_cache_control, :session_options,
14  
-                    :time_zone, :reload_classes_only_on_change, :default_method_for_update
  14
+                    :time_zone, :reload_classes_only_on_change
15 15
 
16 16
       attr_writer :log_level
17 17
       attr_reader :encoding
@@ -40,7 +40,6 @@ def initialize(*)
40 40
         @reload_classes_only_on_change = true
41 41
         @file_watcher                  = ActiveSupport::FileUpdateChecker
42 42
         @exceptions_app                = nil
43  
-        @default_method_for_update     = :put
44 43
         @autoflush_log                 = true
45 44
 
46 45
         @assets = ActiveSupport::OrderedOptions.new
3  railties/lib/rails/generators/rails/app/templates/config/application.rb
@@ -31,9 +31,6 @@ class Application < Rails::Application
31 31
     # Activate observers that should always be running.
32 32
     # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
33 33
 
34  
-    # Use PATCH as default method for update actions
35  
-    # config.default_method_for_update = :patch
36  
-
37 34
     # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
38 35
     # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
39 36
     # config.time_zone = 'Central Time (US & Canada)'
4  railties/test/application/configuration_test.rb
@@ -268,7 +268,6 @@ def update
268 268
       RUBY
269 269
 
270 270
       add_to_config <<-RUBY
271  
-        config.default_method_for_update = :patch
272 271
         routes.prepend do
273 272
           resources :posts
274 273
         end
@@ -276,9 +275,6 @@ def update
276 275
 
277 276
       require "#{app_path}/config/environment"
278 277
 
279  
-      assert_equal ActionView::Base.default_method_for_update, :patch
280  
-      assert_equal ActionDispatch::Routing::Mapper.default_method_for_update, :patch
281  
-
282 278
       get "/posts/1"
283 279
       assert_match /patch/, last_response.body
284 280
 
5  railties/test/generators/app_generator_test.rb
@@ -325,11 +325,6 @@ def test_no_active_record_or_test_unit_if_skips_given
325 325
     assert_file "config/application.rb", /#\s+require\s+["']active_record\/railtie["']/
326 326
   end
327 327
 
328  
-  def test_default_method_for_update_is_not_patch
329  
-    run_generator [destination_root, "--skip-test-unit", "--skip-active-record"]
330  
-    assert_file "config/application.rb", /#\s+config\.default_method_for_update\s+=\s+:patch/
331  
-  end
332  
-
333 328
   def test_new_hash_style
334 329
     run_generator [destination_root]
335 330
     assert_file "config/initializers/session_store.rb" do |file|

0 notes on commit b7a0945

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