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
Jeff1
(Jeff)
August 18, 2008, 5:30pm
2
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: Purple Workshops
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?