diff options
author | Amparo Luna + Guillermo Iguaran <amparo.m.luna@gmail.com+guilleiguaran@gmail.com> | 2013-01-02 16:55:29 -0500 |
---|---|---|
committer | Amparo Luna + Guillermo Iguaran <amparo.m.luna@gmail.com+guilleiguaran@gmail.com> | 2013-01-03 12:04:25 -0500 |
commit | 0433d79724fc2f97208b1e3aec43335c7c33f7cc (patch) | |
tree | 671b73d845007002ea0d0a1da6a479a9cbe1a262 | |
parent | 03ac174f2d35c92ffefd35a7f69369eb5117d8a7 (diff) | |
download | rails-0433d79724fc2f97208b1e3aec43335c7c33f7cc.tar.gz rails-0433d79724fc2f97208b1e3aec43335c7c33f7cc.tar.bz2 rails-0433d79724fc2f97208b1e3aec43335c7c33f7cc.zip |
Updating default application templates to use update instead of update_attributes
4 files changed, 6 insertions, 6 deletions
diff --git a/railties/lib/rails/generators/active_model.rb b/railties/lib/rails/generators/active_model.rb index 0e51b9c568..6183944bb0 100644 --- a/railties/lib/rails/generators/active_model.rb +++ b/railties/lib/rails/generators/active_model.rb @@ -59,8 +59,8 @@ module Rails end # PATCH/PUT update - def update_attributes(params=nil) - "#{name}.update_attributes(#{params})" + def update(params=nil) + "#{name}.update(#{params})" end # POST create 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 4baad85e9e..2512ce0af1 100644 --- a/railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb +++ b/railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb @@ -71,7 +71,7 @@ class <%= controller_class_name %>Controller < ApplicationController # PATCH/PUT <%= route_url %>/1.json def update respond_to do |format| - if @<%= orm_instance.update_attributes("#{singular_table_name}_params") %> + if @<%= orm_instance.update("#{singular_table_name}_params") %> <%- if options[:html] -%> format.html { redirect_to @<%= singular_table_name %>, notice: <%= "'#{human_name} was successfully updated.'" %> } <%- end -%> diff --git a/railties/test/generators/scaffold_controller_generator_test.rb b/railties/test/generators/scaffold_controller_generator_test.rb index f13305adb0..290e4b57cc 100644 --- a/railties/test/generators/scaffold_controller_generator_test.rb +++ b/railties/test/generators/scaffold_controller_generator_test.rb @@ -35,7 +35,7 @@ class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase end assert_instance_method :update, content do |m| - assert_match(/@user\.update_attributes\(user_params\)/, m) + assert_match(/@user\.update\(user_params\)/, m) assert_match(/@user\.errors/, m) end diff --git a/railties/test/generators/scaffold_generator_test.rb b/railties/test/generators/scaffold_generator_test.rb index f3f2c170ee..fbc9cd1321 100644 --- a/railties/test/generators/scaffold_generator_test.rb +++ b/railties/test/generators/scaffold_generator_test.rb @@ -45,7 +45,7 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase end assert_instance_method :update, content do |m| - assert_match(/@product_line\.update_attributes\(product_line_params\)/, m) + assert_match(/@product_line\.update\(product_line_params\)/, m) assert_match(/@product_line\.errors/, m) end @@ -162,7 +162,7 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase end assert_instance_method :update, content do |m| - assert_match(/@admin_role\.update_attributes\(admin_role_params\)/, m) + assert_match(/@admin_role\.update\(admin_role_params\)/, m) assert_match(/@admin_role\.errors/, m) end |