# ActionController::MethodNotAllowed: Only get, put, and delete requests are allowed

**URL:** <https://www.ruby-forum.com/t/actioncontroller-only-get-put-and-delete-requests-are-allowed/150699>\
**Category:** Rails\
**Created:** [October 11, 2008, 7:18pm UTC](https://www.ruby-forum.com/t/actioncontroller-only-get-put-and-delete-requests-are-allowed/150699 "2008-10-11T19:18:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeanluca](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/74df32/32.png) [@jeanluca](https://www.ruby-forum.com/u/jeanluca)\
**Post date:** [October 11, 2008, 7:18pm UTC](https://www.ruby-forum.com/t/actioncontroller-only-get-put-and-delete-requests-are-allowed/150699/1 "2008-10-11T19:18:06Z")

</div>

Hi all,

I’d need some help with a Subject already appeared here, anyway I “re-  
post” with same title cause reading the old threads didn’t help me.

I get a tipical restful routes mismatching :

```
            ActionController::MethodNotAllowed: Only get, put, and

```

delete requests are allowed.

but after several try & errors, I don’t actually understand what’s  
wrong with it, here are salients bits …

rails -v :  
Rails 2.1.1

rake routes :

```
             create_services POST /services/

```

create  
{:action=\>“create”, :controller=\>“services”}  
formatted\_create\_services POST /services/  
create.:format  
{:action=\>“create”, :controller=\>“services”}

the patrial which get in error ( \_delicious.html.erb ):

\<% form\_for @service.url, create\_services\_path do |f| %\>  
\<%= f.error\_messages %\>

\<%= image\_tag("/images/sites\_icons/delicious.png") -%\> \<%= f.hidden\_field :url, :value =\> 'http://delicious.com/' %\> \<%= f.label :delicious %\> \<%= f.text\_field :username %\>

\<%= f.submit "Create" %\>

\<% end %\>

part of my routes file ( config/routes.rb ):

```
          map.resources :services, :collection => { :create

```

=\> :post }

I know should be something stupid, anyway “I’m losing hours” without  
success !  
Any suggestion will be very apreciated.

thz in advance  
luca  
++++++++++++++  
Request

Parameters:

{“commit”=\>“Create”,  
“delicious”=\>{“url”=\>“[http://delicious.com/](http://delicious.com/)”,  
“username”=\>“lgsicious”},  
“authenticity\_token”=\>“xxxxxxxxxxxxxxx”}  
++++++++++++++  
Response

Headers:

{“cookie”=\>[],  
“Cache-Control”=\>“no-cache”,  
“Allow”=\>“GET,  
PUT,  
DELETE”}  
+++++++++++++++

---

<div class="post-metadata">

**Author:** ![jeanluca](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/74df32/32.png) [@jeanluca](https://www.ruby-forum.com/u/jeanluca)\
**Post date:** [October 11, 2008, 10:02pm UTC](https://www.ruby-forum.com/t/actioncontroller-only-get-put-and-delete-requests-are-allowed/150699/2 "2008-10-11T22:02:41Z")

</div>

That happens to me when I edit the routes and forget to restart my  
server.

Ramon T.

---

<div class="post-metadata">

**Author:** ![jeanluca](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/74df32/32.png) [@jeanluca](https://www.ruby-forum.com/u/jeanluca)\
**Post date:** [October 12, 2008, 12:29am UTC](https://www.ruby-forum.com/t/actioncontroller-only-get-put-and-delete-requests-are-allowed/150699/3 "2008-10-12T00:29:02Z")

</div>

Hi Luca,

First, you don’t need this =\> :collection =\> { :create =\> :post }

just:

map.resources :services

Will do the trick.

Also, your form should be like this:

\<% form\_for @service do |f| %\>  
\<%= f.error\_messages %\>

\<%= image\_tag("/images/sites\_icons/delicious.png") -%\> \<%= f.hidden\_field :url, :value =\> 'http://delicious.com/' %\> \<%= f.label :delicious %\> \<%= f.text\_field :username %\>

\<%= f.submit "Create" %\>

\<% end %\>

Try this and see if it works.

On Sat, Oct 11, 2008 at 2:17 PM, lgs [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> delete requests are allowed.  
> create  
> \<%= image\_tag(“/images/sites\_icons/delicious.png”) -%\>
> 
> Request  
> Headers:
> 
> {“cookie”=\>[],  
> “Cache-Control”=\>“no-cache”,  
> “Allow”=\>“GET,  
> PUT,  
> DELETE”}  
> +++++++++++++++
> 
> >

–  
Maurício Linhares  
[http://alinhavado.wordpress.com/](http://alinhavado.wordpress.com/) (pt-br) | [http://blog.codevader.com/](http://blog.codevader.com/)  
(en)  
João Pessoa, PB, +55 83 8867-7208
