# Model.update\_attributes vs. Model.update in Edge Rails!

**URL:** <https://www.ruby-forum.com/t/model-update-attributes-vs-model-update-in-edge-rails/119598>\
**Category:** Rails\
**Created:** [November 8, 2007, 9:53am UTC](https://www.ruby-forum.com/t/model-update-attributes-vs-model-update-in-edge-rails/119598 "2007-11-08T09:53:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sideshow](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3e96dc/32.png) [@sideshow](https://www.ruby-forum.com/u/sideshow)\
**Post date:** [November 8, 2007, 9:53am UTC](https://www.ruby-forum.com/t/model-update-attributes-vs-model-update-in-edge-rails/119598/1 "2007-11-08T09:53:01Z")

</div>

Does any one else find it a pain in the butt that in the new edge  
rails the Model.update method has been made private so throws an error  
if you use it.  
Most of the time i find i need to do work on POST params[] before i  
save them back to the database.

I was doing it like this which seemed really nice and easy;

@widget = Widget.find(params[:id])  
@widget.title = “NEW TITLE”  
@widget.description = params[:description]  
@widget.edited\_by = session[:user\_id]  
@widget.update()

now with edge rails it would seem the only way to do this is (as the  
update method is private):

@widget = Widget.find(params[:id])  
@var = []  
@var[:title] = “NEW TITLE”  
@var[:description] = params[:description]  
@var[:edited\_by] = session[:user\_id]  
@widget.update\_attributes(@var)

Which looks like crap and takes longer to write …or am i missing  
something?  
It seems that the update\_attributes method calls the update method  
internally anyway so was just wondering why they changed this.

---

<div class="post-metadata">

**Author:** ![sideshow](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3e96dc/32.png) [@sideshow](https://www.ruby-forum.com/u/sideshow)\
**Post date:** [November 8, 2007, 10:32am UTC](https://www.ruby-forum.com/t/model-update-attributes-vs-model-update-in-edge-rails/119598/2 "2007-11-08T10:32:51Z")

</div>

On 8 Nov 2007, at 08:52, Adam J. wrote:

> I was doing it like this which seemed really nice and easy;
> 
> @widget = Widget.find(params[:id])  
> @widget.title = “NEW TITLE”  
> @widget.description = params[:description]  
> @widget.edited\_by = session[:user\_id]  
> @widget.update()  
> Why aren’t you calling widget.save ?

Fred

---

<div class="post-metadata">

**Author:** ![sideshow](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3e96dc/32.png) [@sideshow](https://www.ruby-forum.com/u/sideshow)\
**Post date:** [November 8, 2007, 10:39am UTC](https://www.ruby-forum.com/t/model-update-attributes-vs-model-update-in-edge-rails/119598/3 "2007-11-08T10:39:52Z")

</div>

Thanks, That worked…i had always used update for some reason.
