Updating default application templates to use update instead of update_attributes

上级 03ac174f
...@@ -59,8 +59,8 @@ def save ...@@ -59,8 +59,8 @@ def save
end end
# PATCH/PUT update # PATCH/PUT update
def update_attributes(params=nil) def update(params=nil)
"#{name}.update_attributes(#{params})" "#{name}.update(#{params})"
end end
# POST create # POST create
......
...@@ -71,7 +71,7 @@ def create ...@@ -71,7 +71,7 @@ def create
# PATCH/PUT <%= route_url %>/1.json # PATCH/PUT <%= route_url %>/1.json
def update def update
respond_to do |format| respond_to do |format|
if @<%= orm_instance.update_attributes("#{singular_table_name}_params") %> if @<%= orm_instance.update("#{singular_table_name}_params") %>
<%- if options[:html] -%> <%- if options[:html] -%>
format.html { redirect_to @<%= singular_table_name %>, notice: <%= "'#{human_name} was successfully updated.'" %> } format.html { redirect_to @<%= singular_table_name %>, notice: <%= "'#{human_name} was successfully updated.'" %> }
<%- end -%> <%- end -%>
......
...@@ -35,7 +35,7 @@ def test_controller_skeleton_is_created ...@@ -35,7 +35,7 @@ def test_controller_skeleton_is_created
end end
assert_instance_method :update, content do |m| 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) assert_match(/@user\.errors/, m)
end end
......
...@@ -45,7 +45,7 @@ def test_scaffold_on_invoke ...@@ -45,7 +45,7 @@ def test_scaffold_on_invoke
end end
assert_instance_method :update, content do |m| 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) assert_match(/@product_line\.errors/, m)
end end
...@@ -162,7 +162,7 @@ def test_scaffold_with_namespace_on_invoke ...@@ -162,7 +162,7 @@ def test_scaffold_with_namespace_on_invoke
end end
assert_instance_method :update, content do |m| 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) assert_match(/@admin_role\.errors/, m)
end end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册