Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is ActiveRecord::Base#update_attributes deprecated?

I noticed in the Rails docs here that the update_attributes method is deprecated:

This method is deprecated on the latest stable version of Rails. The last existing version (v2.3.8) is shown here.

I'm curious to know why it was deprecated and what is preferred in its place.

It isn't a matter of enormous consequence for me right now as the method works fine in my Rails 2.x apps. However, in anticipation of upgrading to Rails 3 some day I'd like to start getting a grasp on what I'll need to change and how things are done differently.

like image 313
Ethan Avatar asked Apr 25 '11 01:04

Ethan


1 Answers

Apidock is a little misleading, it actually says "deprecated or moved"; the latter is true, the former is not. ActiveRecord::Base includes ActiveRecord::Persistence, which defines #update_attributes. You can view the docs for this on apidock at http://apidock.com/rails/ActiveRecord/Persistence/update_attributes.

While this is also in ActiveResource now, there's no shared implementation of update_attributes, and you shouldn't look there for ActiveRecord::Base-related documentation, or vice versa.

like image 193
carpeliam Avatar answered Sep 20 '22 09:09

carpeliam