diff options
Diffstat (limited to 'railties/lib')
4 files changed, 10 insertions, 6 deletions
diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb index 825ea985fc..0297c41274 100644 --- a/railties/lib/rails/application/configuration.rb +++ b/railties/lib/rails/application/configuration.rb @@ -11,7 +11,7 @@ module Rails :force_ssl, :helpers_paths, :logger, :log_tags, :preload_frameworks, :railties_order, :relative_url_root, :secret_token, :serve_static_assets, :ssl_options, :static_cache_control, :session_options, - :time_zone, :reload_classes_only_on_change + :time_zone, :reload_classes_only_on_change, :default_method_for_update attr_writer :log_level attr_reader :encoding @@ -40,6 +40,7 @@ module Rails @reload_classes_only_on_change = true @file_watcher = ActiveSupport::FileUpdateChecker @exceptions_app = nil + @default_method_for_update = :put @assets = ActiveSupport::OrderedOptions.new @assets.enabled = false diff --git a/railties/lib/rails/generators/active_model.rb b/railties/lib/rails/generators/active_model.rb index 4b828340d2..f51028b657 100644 --- a/railties/lib/rails/generators/active_model.rb +++ b/railties/lib/rails/generators/active_model.rb @@ -37,7 +37,7 @@ module Rails # GET show # GET edit - # PUT update + # PUT/PATCH update # DELETE destroy def self.find(klass, params=nil) "#{klass}.find(#{params})" @@ -58,13 +58,13 @@ module Rails "#{name}.save" end - # PUT update + # PUT/PATCH update def update_attributes(params=nil) "#{name}.update_attributes(#{params})" end # POST create - # PUT update + # PUT/PATCH update def errors "#{name}.errors" end diff --git a/railties/lib/rails/generators/rails/app/templates/config/application.rb b/railties/lib/rails/generators/rails/app/templates/config/application.rb index acf47a03e5..c970c2cf44 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/application.rb +++ b/railties/lib/rails/generators/rails/app/templates/config/application.rb @@ -31,6 +31,9 @@ module <%= app_const_base %> # Activate observers that should always be running. # config.active_record.observers = :cacher, :garbage_collector, :forum_observer + # Use PATCH as default method for update actions + # config.default_method_for_update = :patch + # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. # config.time_zone = 'Central Time (US & Canada)' diff --git a/railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb b/railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb index 4ff15fd288..566d78c6eb 100644 --- a/railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb +++ b/railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb @@ -54,8 +54,8 @@ class <%= controller_class_name %>Controller < ApplicationController end end - # PUT <%= route_url %>/1 - # PUT <%= route_url %>/1.json + # PUT/PATCH <%= route_url %>/1 + # PUT/PATCH <%= route_url %>/1.json def update @<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %> |