# RESTful routes problem when updating record

**URL:** <https://www.ruby-forum.com/t/restful-routes-problem-when-updating-record/170069>\
**Category:** Rails\
**Created:** [June 11, 2009, 10:40pm UTC](https://www.ruby-forum.com/t/restful-routes-problem-when-updating-record/170069 "2009-06-11T22:40:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![lyntaff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/87869e/32.png) [@lyntaff](https://www.ruby-forum.com/u/lyntaff)\
**Post date:** [June 11, 2009, 10:40pm UTC](https://www.ruby-forum.com/t/restful-routes-problem-when-updating-record/170069/1 "2009-06-11T22:40:37Z")

</div>

I get an error when trying to update a record when using a HTTP  
request PUT method from a form complying with the RESTful routing for  
the resource.

The error is: Only get and post requests are allowed.

Has anybody come accross this before?

Hope somebody can help.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![lyntaff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/87869e/32.png) [@lyntaff](https://www.ruby-forum.com/u/lyntaff)\
**Post date:** [June 12, 2009, 2:52pm UTC](https://www.ruby-forum.com/t/restful-routes-problem-when-updating-record/170069/2 "2009-06-12T14:52:02Z")

</div>

> The error is: Only get and post requests are allowed.

This seems pretty straight forward…

What does your routes.rb look like?

For the model in question, does your like look something like:

map.resources :mymodels, :member =\> {:myaction =\> :put}

You’re trying to use a PUT, but have you told Rails to accept that for  
that action?

---

<div class="post-metadata">

**Author:** ![lyntaff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/87869e/32.png) [@lyntaff](https://www.ruby-forum.com/u/lyntaff)\
**Post date:** [June 12, 2009, 3:26pm UTC](https://www.ruby-forum.com/t/restful-routes-problem-when-updating-record/170069/3 "2009-06-12T15:26:58Z")

</div>

In my routes.rb I only have:

map.resources :mymodel

Am I correct in saying that the PUT method is set automatically in the  
RESTful routes while setting the resource?

---

<div class="post-metadata">

**Author:** ![lyntaff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/87869e/32.png) [@lyntaff](https://www.ruby-forum.com/u/lyntaff)\
**Post date:** [June 12, 2009, 3:55pm UTC](https://www.ruby-forum.com/t/restful-routes-problem-when-updating-record/170069/4 "2009-06-12T15:55:09Z")

</div>

In my routes.rb I only have:

map.resources :mymodel

Am I correct in saying that the PUT method is set automatically in the  
RESTful routes while setting the resource?

---

<div class="post-metadata">

**Author:** ![lyntaff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/87869e/32.png) [@lyntaff](https://www.ruby-forum.com/u/lyntaff)\
**Post date:** [June 12, 2009, 7:14pm UTC](https://www.ruby-forum.com/t/restful-routes-problem-when-updating-record/170069/5 "2009-06-12T19:14:32Z")

</div>

Lyn Williams wrote:

> In my routes.rb I only have:
> 
> map.resources :mymodel
> 
> Am I correct in saying that the PUT method is set automatically in the  
> RESTful routes while setting the resource?

[http://api.rubyonrails.org/classes/ActionController/Resources.html](http://api.rubyonrails.org/classes/ActionController/Resources.html)

---

<div class="post-metadata">

**Author:** ![lyntaff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/87869e/32.png) [@lyntaff](https://www.ruby-forum.com/u/lyntaff)\
**Post date:** [June 12, 2009, 8:33pm UTC](https://www.ruby-forum.com/t/restful-routes-problem-when-updating-record/170069/6 "2009-06-12T20:33:50Z")

</div>

This route allows put requests on the update action which is routed to  
the url :controller/:id

2009/6/12, lyntaff [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> >

–  
Von meinen Mobilgerät aus gesendet
