Skip to content
Browse files

consistently mention first patch, then put

There was a mix, sometimes patch first, sometimes put first.
Use always patch first, since this is going to be the
primary verb for updates.
  • Loading branch information...
1 parent b7a0945 commit 3008188cd6c0cca8789e8b7c57a4f896e2ff07d5 @fxn fxn committed Feb 24, 2012
View
14 actionpack/lib/action_dispatch/routing/mapper.rb
@@ -537,7 +537,7 @@ def map_method(method, args, &block)
# POST /admin/posts
# GET /admin/posts/1
# GET /admin/posts/1/edit
- # PUT/PATCH /admin/posts/1
+ # PATCH/PUT /admin/posts/1
# DELETE /admin/posts/1
#
# If you want to route /posts (without the prefix /admin) to
@@ -571,7 +571,7 @@ def map_method(method, args, &block)
# POST /admin/posts
# GET /admin/posts/1
# GET /admin/posts/1/edit
- # PUT/PATCH /admin/posts/1
+ # PATCH/PUT /admin/posts/1
# DELETE /admin/posts/1
module Scoping
# Scopes a set of routes to the given default options.
@@ -666,7 +666,7 @@ def controller(controller, options={})
# new_admin_post GET /admin/posts/new(.:format) admin/posts#new
# edit_admin_post GET /admin/posts/:id/edit(.:format) admin/posts#edit
# admin_post GET /admin/posts/:id(.:format) admin/posts#show
- # admin_post PUT/PATCH /admin/posts/:id(.:format) admin/posts#update
+ # admin_post PATCH/PUT /admin/posts/:id(.:format) admin/posts#update
# admin_post DELETE /admin/posts/:id(.:format) admin/posts#destroy
#
# === Options
@@ -986,7 +986,7 @@ def resources_path_names(options)
# POST /geocoder
# GET /geocoder
# GET /geocoder/edit
- # PUT/PATCH /geocoder
+ # PATCH/PUT /geocoder
# DELETE /geocoder
#
# === Options
@@ -1038,7 +1038,7 @@ def resource(*resources, &block)
# POST /photos
# GET /photos/:id
# GET /photos/:id/edit
- # PUT/PATCH /photos/:id
+ # PATCH/PUT /photos/:id
# DELETE /photos/:id
#
# Resources can also be nested infinitely by using this block syntax:
@@ -1054,7 +1054,7 @@ def resource(*resources, &block)
# POST /photos/:photo_id/comments
# GET /photos/:photo_id/comments/:id
# GET /photos/:photo_id/comments/:id/edit
- # PUT/PATCH /photos/:photo_id/comments/:id
+ # PATCH/PUT /photos/:photo_id/comments/:id
# DELETE /photos/:photo_id/comments/:id
#
# === Options
@@ -1122,7 +1122,7 @@ def resource(*resources, &block)
# new_post_comment GET /posts/:post_id/comments/new(.:format)
# edit_comment GET /sekret/comments/:id/edit(.:format)
# comment GET /sekret/comments/:id(.:format)
- # comment PUT/PATCH /sekret/comments/:id(.:format)
+ # comment PATCH/PUT /sekret/comments/:id(.:format)
# comment DELETE /sekret/comments/:id(.:format)
#
# === Examples
View
2 actionpack/lib/action_dispatch/testing/integration.rb
@@ -330,7 +330,7 @@ def reset!
@integration_session = Integration::Session.new(app)
end
- %w(get post put patch head delete options cookies assigns
+ %w(get post patch put head delete options cookies assigns
xml_http_request xhr get_via_redirect post_via_redirect).each do |method|
define_method(method) do |*args|
reset! unless integration_session
View
2 actionpack/lib/action_view/helpers/url_helper.rb
@@ -329,7 +329,7 @@ def button_to(name, options = {}, html_options = {})
remote = html_options.delete('remote')
method = html_options.delete('method').to_s
- method_tag = %w{put patch delete}.include?(method) ? method_tag(method) : ""
+ method_tag = %w{patch put delete}.include?(method) ? method_tag(method) : ""
form_method = method == 'get' ? 'get' : 'post'
form_options = html_options.delete('form') || {}
View
2 activeresource/lib/active_resource/custom_methods.rb
@@ -12,7 +12,7 @@ module ActiveResource
# This route set creates routes for the following HTTP requests:
#
# POST /people/new/register.json # PeopleController.register
- # PUT/PATCH /people/1/promote.json # PeopleController.promote with :id => 1
+ # PATCH/PUT /people/1/promote.json # PeopleController.promote with :id => 1
# DELETE /people/1/deactivate.json # PeopleController.deactivate with :id => 1
# GET /people/active.json # PeopleController.active
#
View
6 activeresource/lib/active_resource/http_mock.rb
@@ -55,7 +55,7 @@ def initialize(responses)
@responses = responses
end
- [ :post, :put, :patch, :get, :delete, :head ].each do |method|
+ [ :post, :patch, :put, :get, :delete, :head ].each do |method|
# def post(path, request_headers = {}, body = nil, status = 200, response_headers = {})
# @responses[Request.new(:post, path, nil, request_headers)] = Response.new(body || "", status, response_headers)
# end
@@ -291,9 +291,9 @@ def initialize(body, message = 200, headers = {})
if resp_cls && !resp_cls.body_permitted?
@body = nil
end
-
+
self['Content-Length'] = @body.nil? ? "0" : body.size.to_s
-
+
end
# Returns true if code is 2xx,
View
4 railties/guides/source/ajax_on_rails.textile
@@ -147,7 +147,7 @@ link_to_remote "Add new item",
</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/PATCH) 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:
+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",
@@ -168,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>
View
2 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, PATCH, 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.
View
16 railties/guides/source/routing.textile
@@ -82,7 +82,7 @@ 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/PATCH |/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.
@@ -137,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/PATCH |/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.
@@ -168,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/PATCH |/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
@@ -207,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/PATCH |/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
@@ -240,7 +240,7 @@ In addition to the routes for magazines, this declaration will also route ads to
|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/PATCH |/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)+).
@@ -640,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/PATCH |/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.
@@ -684,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/PATCH |/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
@@ -788,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/PATCH |/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
View
6 railties/lib/rails/generators/active_model.rb
@@ -37,7 +37,7 @@ def self.all(klass)
# GET show
# GET edit
- # PUT/PATCH update
+ # PATCH/PUT update
# DELETE destroy
def self.find(klass, params=nil)
"#{klass}.find(#{params})"
@@ -58,13 +58,13 @@ def save
"#{name}.save"
end
- # PUT/PATCH update
+ # PATCH/PUT update
def update_attributes(params=nil)
"#{name}.update_attributes(#{params})"
end
# POST create
- # PUT/PATCH update
+ # PATCH/PUT update
def errors
"#{name}.errors"
end
View
4 railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb
@@ -54,8 +54,8 @@ def create
end
end
- # PUT/PATCH <%= route_url %>/1
- # PUT/PATCH <%= route_url %>/1.json
+ # PATCH/PUT <%= route_url %>/1
+ # PATCH/PUT <%= route_url %>/1.json
def update
@<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %>

0 comments on commit 3008188

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