Skip to content

Commit

Permalink
Updating default application templates to use update instead of updat…
Browse files Browse the repository at this point in the history
…e_attributes
  • Loading branch information
Amparo Luna + Guillermo Iguaran committed Jan 3, 2013
1 parent 03ac174 commit 0433d79
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions railties/lib/rails/generators/active_model.rb
Expand Up @@ -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
Expand Down
Expand Up @@ -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 -%>
Expand Down
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions railties/test/generators/scaffold_generator_test.rb
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 0433d79

Please sign in to comment.