Skip to content

Commit

Permalink
Deprecate Rails::Generators::ActiveModel#update_attributes
Browse files Browse the repository at this point in the history
Deprecate #update_attributes in favor of `#update`.

ORMs that implement `Generators::ActiveModel#update_attributes` should change
to `#update`. Scaffold controller generators should change calls like:

    @orm_instance.update_attributes(...)

to:

    @orm_instance.update(...)

This goes along with the addition of `ActiveRecord::Base#update`,
introduced in cb2bd4a.
  • Loading branch information
carlosantoniodasilva committed Jan 12, 2013
1 parent 9b636dc commit 2549a3b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
15 changes: 15 additions & 0 deletions railties/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
## Rails 4.0.0 (unreleased) ##

* Deprecate `Rails::Generators::ActiveModel#update_attributes` in favor of `#update`.

ORMs that implement `Generators::ActiveModel#update_attributes` should change
to `#update`. Scaffold controller generators should change calls like:

@orm_instance.update_attributes(...)

to:

@orm_instance.update(...)

This goes along with the addition of `ActiveRecord::Base#update`.

*Carlos Antonio da Silva*

* Include `jbuilder` by default and rely on its scaffold generator to show json API.
Check https://github.com/rails/jbuilder for more info and examples.

Expand Down
8 changes: 8 additions & 0 deletions railties/lib/rails/generators/active_model.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'active_support/deprecation'

module Rails
module Generators
# ActiveModel is a class to be implemented by each ORM to allow Rails to
Expand Down Expand Up @@ -63,6 +65,12 @@ def update(params=nil)
"#{name}.update(#{params})"
end

def update_attributes(*args) # :nodoc:
ActiveSupport::Deprecation.warn("Calling '@orm_instance.update_attributes' " \
"is deprecated, please use '@orm_instance.update' instead.")
update(*args)
end

# POST create
# PATCH/PUT update
def errors
Expand Down

0 comments on commit 2549a3b

Please sign in to comment.