diff options
Diffstat (limited to 'railties/guides/source')
-rw-r--r-- | railties/guides/source/action_controller_overview.textile | 2 | ||||
-rw-r--r-- | railties/guides/source/ajax_on_rails.textile | 5 | ||||
-rw-r--r-- | railties/guides/source/configuring.textile | 5 | ||||
-rw-r--r-- | railties/guides/source/form_helpers.textile | 12 | ||||
-rw-r--r-- | railties/guides/source/routing.textile | 30 | ||||
-rw-r--r-- | railties/guides/source/testing.textile | 6 |
6 files changed, 31 insertions, 29 deletions
diff --git a/railties/guides/source/action_controller_overview.textile b/railties/guides/source/action_controller_overview.textile index bc85f07ecc..52d134ace5 100644 --- a/railties/guides/source/action_controller_overview.textile +++ b/railties/guides/source/action_controller_overview.textile @@ -563,7 +563,7 @@ The request object contains a lot of useful information about the request coming |domain(n=2)|The hostname's first +n+ segments, starting from the right (the TLD).| |format|The content type requested by the client.| |method|The HTTP method used for the request.| -|get?, post?, put?, delete?, head?|Returns true if the HTTP method is GET/POST/PUT/DELETE/HEAD.| +|get?, post?, patch?, put?, delete?, head?|Returns true if the HTTP method is GET/POST/PATCH/PUT/DELETE/HEAD.| |headers|Returns a hash containing the headers associated with the request.| |port|The port number (integer) used for the request.| |protocol|Returns a string containing the protocol used plus "://", for example "http://".| diff --git a/railties/guides/source/ajax_on_rails.textile b/railties/guides/source/ajax_on_rails.textile index 3a0ccfe9b2..5913a472fd 100644 --- a/railties/guides/source/ajax_on_rails.textile +++ b/railties/guides/source/ajax_on_rails.textile @@ -146,7 +146,8 @@ link_to_remote "Add new item", :position => :bottom </ruby> -** *:method* Most typically you want to use a POST request when adding a remote link to your view so this is the default behavior. However, sometimes you'll want to update (PUT) or delete/destroy (DELETE) something and you can specify this with the +:method+ option. Let's see an example for a typical AJAX link for deleting an item from a list: +** *:method* Most typically you want to use a POST request when adding a remote +link to your view so this is the default behavior. However, sometimes you'll want to update (PATCH/PUT) or delete/destroy (DELETE) something and you can specify this with the +:method+ option. Let's see an example for a typical AJAX link for deleting an item from a list: <ruby> link_to_remote "Delete the item", @@ -167,7 +168,7 @@ Note that if we wouldn't override the default behavior (POST), the above snippet <ruby> link_to_remote "Update record", :url => record_url(record), - :method => :put, + :method => :patch, :with => "'status=' <plus> 'encodeURIComponent($('status').value) <plus> '&completed=' <plus> $('completed')" </ruby> diff --git a/railties/guides/source/configuring.textile b/railties/guides/source/configuring.textile index 26292a85f5..2f465b37ed 100644 --- a/railties/guides/source/configuring.textile +++ b/railties/guides/source/configuring.textile @@ -214,7 +214,7 @@ Every Rails application comes with a standard set of middleware which it uses in * +ActionDispatch::Session::CookieStore+ is responsible for storing the session in cookies. An alternate middleware can be used for this by changing the +config.action_controller.session_store+ to an alternate value. Additionally, options passed to this can be configured by using +config.action_controller.session_options+. * +ActionDispatch::Flash+ sets up the +flash+ keys. Only available if +config.action_controller.session_store+ is set to a value. * +ActionDispatch::ParamsParser+ parses out parameters from the request into +params+. -* +Rack::MethodOverride+ allows the method to be overridden if +params[:_method]+ is set. This is the middleware which supports the PUT and DELETE HTTP method types. +* +Rack::MethodOverride+ allows the method to be overridden if +params[:_method]+ is set. This is the middleware which supports the PATCH, PUT, and DELETE HTTP method types. * +ActionDispatch::Head+ converts HEAD requests to GET requests and serves them as so. * +ActionDispatch::BestStandardsSupport+ enables "best standards support" so that IE8 renders some elements correctly. @@ -346,7 +346,8 @@ h4. Configuring Action Dispatch h4. Configuring Action View -There are only a few configuration options for Action View, starting with four on +ActionView::Base+: +There are only a few configuration options for Action View, starting with six on +ActionView::Base+: + * +config.action_view.field_error_proc+ provides an HTML generator for displaying errors that come from Active Record. The default is diff --git a/railties/guides/source/form_helpers.textile b/railties/guides/source/form_helpers.textile index 2de4d49cf2..a696e4f8ae 100644 --- a/railties/guides/source/form_helpers.textile +++ b/railties/guides/source/form_helpers.textile @@ -292,7 +292,7 @@ form_for(@article) ## Editing an existing article # long-style: -form_for(@article, :url => article_path(@article), :html => { :method => "put" }) +form_for(@article, :url => article_path(@article), :html => { :method => "patch" }) # short-style: form_for(@article) </ruby> @@ -320,14 +320,14 @@ form_for [:admin, :management, @article] For more information on Rails' routing system and the associated conventions, please see the "routing guide":routing.html. -h4. How do forms with PUT or DELETE methods work? +h4. How do forms with PATCH, PUT, or DELETE methods work? -The Rails framework encourages RESTful design of your applications, which means you'll be making a lot of "PUT" and "DELETE" requests (besides "GET" and "POST"). However, most browsers _don't support_ methods other than "GET" and "POST" when it comes to submitting forms. +The Rails framework encourages RESTful design of your applications, which means you'll be making a lot of "PATCH" and "DELETE" requests (besides "GET" and "POST"). However, most browsers _don't support_ methods other than "GET" and "POST" when it comes to submitting forms. Rails works around this issue by emulating other methods over POST with a hidden input named +"_method"+, which is set to reflect the desired method: <ruby> -form_tag(search_path, :method => "put") +form_tag(search_path, :method => "patch") </ruby> output: @@ -335,14 +335,14 @@ output: <html> <form accept-charset="UTF-8" action="/search" method="post"> <div style="margin:0;padding:0"> - <input name="_method" type="hidden" value="put" /> + <input name="_method" type="hidden" value="patch" /> <input name="utf8" type="hidden" value="✓" /> <input name="authenticity_token" type="hidden" value="f755bb0ed134b76c432144748a6d4b7a7ddf2b71" /> </div> ... </html> -When parsing POSTed data, Rails will take into account the special +_method+ parameter and acts as if the HTTP method was the one specified inside it ("PUT" in this example). +When parsing POSTed data, Rails will take into account the special +_method+ parameter and acts as if the HTTP method was the one specified inside it ("PATCH" in this example). h3. Making Select Boxes with Ease diff --git a/railties/guides/source/routing.textile b/railties/guides/source/routing.textile index 0823fb14e3..df2bd9d0c9 100644 --- a/railties/guides/source/routing.textile +++ b/railties/guides/source/routing.textile @@ -50,7 +50,7 @@ Resource routing allows you to quickly declare all of the common routes for a gi h4. Resources on the Web -Browsers request pages from Rails by making a request for a URL using a specific HTTP method, such as +GET+, +POST+, +PUT+ and +DELETE+. Each method is a request to perform an operation on the resource. A resource route maps a number of related requests to actions in a single controller. +Browsers request pages from Rails by making a request for a URL using a specific HTTP method, such as +GET+, +POST+, +PATCH+, +PUT+ and +DELETE+. Each method is a request to perform an operation on the resource. A resource route maps a number of related requests to actions in a single controller. When your Rails application receives an incoming request for @@ -82,10 +82,9 @@ creates seven different routes in your application, all mapping to the +Photos+ |POST |/photos |create |create a new photo | |GET |/photos/:id |show |display a specific photo | |GET |/photos/:id/edit |edit |return an HTML form for editing a photo | -|PUT |/photos/:id |update |update a specific photo | +|PATCH/PUT |/photos/:id |update |update a specific photo | |DELETE |/photos/:id |destroy |delete a specific photo | - 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. h4. Paths and URLs @@ -138,7 +137,7 @@ creates six different routes in your application, all mapping to the +Geocoders+ |POST |/geocoder |create |create the new geocoder | |GET |/geocoder |show |display the one and only geocoder resource | |GET |/geocoder/edit |edit |return an HTML form for editing the geocoder | -|PUT |/geocoder |update |update the one and only geocoder resource | +|PATCH/PUT |/geocoder |update |update the one and only geocoder resource | |DELETE |/geocoder |destroy |delete the geocoder resource | 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. @@ -169,7 +168,7 @@ This will create a number of routes for each of the +posts+ and +comments+ contr |POST |/admin/posts |create | admin_posts_path | |GET |/admin/posts/:id |show | admin_post_path(:id) | |GET |/admin/posts/:id/edit |edit | edit_admin_post_path(:id) | -|PUT |/admin/posts/:id |update | admin_post_path(:id) | +|PATCH/PUT |/admin/posts/:id |update | admin_post_path(:id) | |DELETE |/admin/posts/:id |destroy | admin_post_path(:id) | If you want to route +/posts+ (without the prefix +/admin+) to +Admin::PostsController+, you could use @@ -208,7 +207,7 @@ In each of these cases, the named routes remain the same as if you did not use + |POST |/admin/posts |create | posts_path | |GET |/admin/posts/:id |show | post_path(:id) | |GET |/admin/posts/:id/edit|edit | edit_post_path(:id)| -|PUT |/admin/posts/:id |update | post_path(:id) | +|PATCH/PUT |/admin/posts/:id |update | post_path(:id) | |DELETE |/admin/posts/:id |destroy | post_path(:id) | h4. Nested Resources @@ -235,16 +234,15 @@ end In addition to the routes for magazines, this declaration will also route ads to an +AdsController+. The ad URLs require a magazine: -|_.HTTP Verb |_.Path |_.action |_.used for | -|GET |/magazines/:id/ads |index |display a list of all ads for a specific magazine | -|GET |/magazines/:id/ads/new |new |return an HTML form for creating a new ad belonging to a specific magazine | -|POST |/magazines/:id/ads |create |create a new ad belonging to a specific magazine | +|_.HTTP Verb |_.Path |_.action |_.used for | +|GET |/magazines/:id/ads |index |display a list of all ads for a specific magazine | +|GET |/magazines/:id/ads/new |new |return an HTML form for creating a new ad belonging to a specific magazine | +|POST |/magazines/:id/ads |create |create a new ad belonging to a specific magazine | |GET |/magazines/:id/ads/:id |show |display a specific ad belonging to a specific magazine | |GET |/magazines/:id/ads/:id/edit |edit |return an HTML form for editing an ad belonging to a specific magazine | -|PUT |/magazines/:id/ads/:id |update |update a specific ad belonging to a specific magazine | +|PATCH/PUT |/magazines/:id/ads/:id |update |update a specific ad belonging to a specific magazine | |DELETE |/magazines/:id/ads/:id |destroy |delete a specific ad belonging to a specific magazine | - 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)+). h5. Limits to Nesting @@ -323,7 +321,7 @@ end This will recognize +/photos/1/preview+ with GET, and route to the +preview+ action of +PhotosController+. It will also create the +preview_photo_url+ and +preview_photo_path+ helpers. -Within the block of member routes, each route name specifies the HTTP verb that it will recognize. You can use +get+, +put+, +post+, or +delete+ here. If you don't have multiple +member+ routes, you can also pass +:on+ to a route, eliminating the block: +Within the block of member routes, each route name specifies the HTTP verb that it will recognize. You can use +get+, +patch+, +put+, +post+, or +delete+ here. If you don't have multiple +member+ routes, you can also pass +:on+ to a route, eliminating the block: <ruby> resources :photos do @@ -642,7 +640,7 @@ will recognize incoming paths beginning with +/photos+ but route to the +Images+ |POST |/photos |create | photos_path | |GET |/photos/:id |show | photo_path(:id) | |GET |/photos/:id/edit |edit | edit_photo_path(:id) | -|PUT |/photos/:id |update | photo_path(:id) | +|PATCH/PUT |/photos/:id |update | photo_path(:id) | |DELETE |/photos/:id |destroy | photo_path(:id) | NOTE: Use +photos_path+, +new_photo_path+, etc. to generate paths for this resource. @@ -686,7 +684,7 @@ will recognize incoming paths beginning with +/photos+ and route the requests to |POST |/photos |create | images_path | |GET |/photos/:id |show | image_path(:id) | |GET |/photos/:id/edit |edit | edit_image_path(:id) | -|PUT |/photos/:id |update | image_path(:id) | +|PATCH/PUT |/photos/:id |update | image_path(:id) | |DELETE |/photos/:id |destroy | image_path(:id) | h4. Overriding the +new+ and +edit+ Segments @@ -790,7 +788,7 @@ Rails now creates routes to the +CategoriesController+. |POST |/kategorien |create | categories_path | |GET |/kategorien/:id |show | category_path(:id) | |GET |/kategorien/:id/bearbeiten |edit | edit_category_path(:id) | -|PUT |/kategorien/:id |update | category_path(:id) | +|PATCH/PUT |/kategorien/:id |update | category_path(:id) | |DELETE |/kategorien/:id |destroy | category_path(:id) | h4. Overriding the Singular Form diff --git a/railties/guides/source/testing.textile b/railties/guides/source/testing.textile index 1e6b92f45c..c367f532ae 100644 --- a/railties/guides/source/testing.textile +++ b/railties/guides/source/testing.textile @@ -483,10 +483,11 @@ Now you can try running all the tests and they should pass. h4. Available Request Types for Functional Tests -If you're familiar with the HTTP protocol, you'll know that +get+ is a type of request. There are 5 request types supported in Rails functional tests: +If you're familiar with the HTTP protocol, you'll know that +get+ is a type of request. There are 6 request types supported in Rails functional tests: * +get+ * +post+ +* +patch+ * +put+ * +head+ * +delete+ @@ -638,6 +639,7 @@ In addition to the standard testing helpers, there are some additional helpers a |+request_via_redirect(http_method, path, [parameters], [headers])+ |Allows you to make an HTTP request and follow any subsequent redirects.| |+post_via_redirect(path, [parameters], [headers])+ |Allows you to make an HTTP POST request and follow any subsequent redirects.| |+get_via_redirect(path, [parameters], [headers])+ |Allows you to make an HTTP GET request and follow any subsequent redirects.| +|+patch_via_redirect(path, [parameters], [headers])+ |Allows you to make an HTTP PATCH request and follow any subsequent redirects.| |+put_via_redirect(path, [parameters], [headers])+ |Allows you to make an HTTP PUT request and follow any subsequent redirects.| |+delete_via_redirect(path, [parameters], [headers])+ |Allows you to make an HTTP DELETE request and follow any subsequent redirects.| |+open_session+ |Opens a new session instance.| @@ -810,7 +812,7 @@ class PostsControllerTest < ActionController::TestCase end test "should update post" do - put :update, :id => @post.id, :post => { } + patch :update, :id => @post.id, :post => { } assert_redirected_to post_path(assigns(:post)) end |