# Update\_attributes does not work with ActiveResource

**URL:** <https://www.ruby-forum.com/t/update-attributes-does-not-work-with-activeresource/146175>\
**Category:** Rails\
**Created:** [August 18, 2008, 7:13pm UTC](https://www.ruby-forum.com/t/update-attributes-does-not-work-with-activeresource/146175 "2008-08-18T19:13:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jawosis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/f04885/32.png) [@jawosis](https://www.ruby-forum.com/u/jawosis)\
**Post date:** [August 18, 2008, 7:13pm UTC](https://www.ruby-forum.com/t/update-attributes-does-not-work-with-activeresource/146175/1 "2008-08-18T19:13:58Z")

</div>

I have to sites running on port 3000 and 3001

I read the Client model via ActiveResource. Creating and deleting  
is working but updating causes the following error:

NoMethodError in ClientsController#update  
undefined method `update\_attributes’ for #Client:0x22fce78

Is ActiveResource broken?

I run Rails 2.1.0.

Thanx

---

<div class="post-metadata">

**Author:** ![jawosis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/f04885/32.png) [@jawosis](https://www.ruby-forum.com/u/jawosis)\
**Post date:** [August 18, 2008, 7:30pm UTC](https://www.ruby-forum.com/t/update-attributes-does-not-work-with-activeresource/146175/2 "2008-08-18T19:30:58Z")

</div>

On Aug 18, 12:13 pm, Jochen K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I run Rails 2.1.0.
> 
> Thanx

To update a resource, you should be able to just change your  
attributes as desired and then call object.save(). ActiveResource  
should translate that to a PUT request, which the server app should  
then map to the update() action on the server resource.

Unless I’ve misunderstood your question…?

Jeff

REST with Rails  
Oct 4, 2008, Austin TX:  
[http://www.purpleworkshops.com/workshops/rest-and-web-services](http://www.purpleworkshops.com/workshops/rest-and-web-services)

---

<div class="post-metadata">

**Author:** ![jawosis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/f04885/32.png) [@jawosis](https://www.ruby-forum.com/u/jawosis)\
**Post date:** [August 18, 2008, 7:40pm UTC](https://www.ruby-forum.com/t/update-attributes-does-not-work-with-activeresource/146175/3 "2008-08-18T19:40:56Z")

</div>

Am 18.08.2008 um 19:30 schrieb Jeff:

> > Is ActiveResource broken?
> > 
> > I run Rails 2.1.0.
> > 
> > Thanx
> 
> To update a resource, you should be able to just change your  
> attributes as desired and then call object.save(). ActiveResource  
> should translate that to a PUT request, which the server app should  
> then map to the update() action on the server resource.

Ok, I just changed this:

def update  
@client = Client.find(params[:id])

```
 respond_to do |format|
   # if @client.update_attributes(params[:client])
   if 1 == 1
     @client.lastname = "BLAHBLAH"
     @client.save
     flash[:notice] = 'Client was successfully updated.'
     format.html { redirect_to(@client) }
     format.xml { head :ok }
   else
     format.html { render :action => "edit" }
     format.xml { render :xml => @client.errors, :status

```

=\> :unprocessable\_entity }  
end  
end  
end

It works! THanx. So the standard code generated by script/generate …  
is useless?
