Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updating default application templates to use update instead of updat…

…e_attributes
  • Loading branch information...
commit 0433d79724fc2f97208b1e3aec43335c7c33f7cc 1 parent 03ac174
Amparo Luna + Guillermo Iguaran authored
View
4 railties/lib/rails/generators/active_model.rb
@@ -59,8 +59,8 @@ def save
end
# PATCH/PUT update
- def update_attributes(params=nil)
- "#{name}.update_attributes(#{params})"
+ def update(params=nil)
+ "#{name}.update(#{params})"
end
# POST create
View
2  railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb
@@ -71,7 +71,7 @@ def create
# 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 -%>
View
2  railties/test/generators/scaffold_controller_generator_test.rb
@@ -35,7 +35,7 @@ def test_controller_skeleton_is_created
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
View
4 railties/test/generators/scaffold_generator_test.rb
@@ -45,7 +45,7 @@ def test_scaffold_on_invoke
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 @@ def test_scaffold_with_namespace_on_invoke
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
Please sign in to comment.
Something went wrong with that request. Please try again.