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
On Aug 18, 12:13 pm, Jochen K. [email protected] 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
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?