# Form causing error =\> "Only post requests are allowed"?

**URL:** <https://www.ruby-forum.com/t/form-causing-error-only-post-requests-are-allowed/142964>\
**Category:** Rails\
**Created:** [July 14, 2008, 1:37am UTC](https://www.ruby-forum.com/t/form-causing-error-only-post-requests-are-allowed/142964 "2008-07-14T01:37:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![scottnj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b9e5f3/32.png) [@scottnj](https://www.ruby-forum.com/u/scottnj)\
**Post date:** [July 14, 2008, 1:37am UTC](https://www.ruby-forum.com/t/form-causing-error-only-post-requests-are-allowed/142964/1 "2008-07-14T01:37:25Z")

</div>

Why does the form give the error “Only post requests are allowed.”  
when submitted to my action? I know the form is supposed to be a post.  
the rake routes looks ok. some reason there is a “\_method”=\>“put” in  
the reques parameters, would this cause it? how do i change the form  
code to prevent this?

## Request

## Parameters:

{“commit”=\>“Save”,  
“\_method”=\>“put”,  
“authenticity\_token”=\>“291f0f51779490f481edec3fef506b14a2797263”,  
“address”=\>{“address”=\>“123 some street, boston, ma”}}

## rake routes

verify\_edit\_club\_address  
POST  
/clubs/:club\_id/addresses/:id/verify\_edit  
{:controller=\>“addresses”, :action=\>“verify\_edit”}

## form.html.erb

\<% form\_for([@club, @address], :url =\>  
verify\_edit\_club\_address\_path(@club, @address)) do |f| -%\>

**Address**  
 \<%= f.text\_area :address %\>

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

\<% end -%\>
## html of generated form

**Address**  
 123 some street, boston, ma

---

<div class="post-metadata">

**Author:** ![scottnj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b9e5f3/32.png) [@scottnj](https://www.ruby-forum.com/u/scottnj)\
**Post date:** [July 14, 2008, 11:10am UTC](https://www.ruby-forum.com/t/form-causing-error-only-post-requests-are-allowed/142964/2 "2008-07-14T11:10:10Z")

</div>

> \<% form\_for([@club, @address], :url =\>  
> verify\_edit\_club\_address\_path(@club, @address)) do |f| -%\>

This way, Rails should be able to find out the right method by itself.  
It depends on the state of @address.  
If it’s generated with  
@address = Adress.new()  
and not saved, it’ll generate a put, otherwise if it’s based on an  
record in the db, (eg Address.find(…)) it’ll be a post

But you can change the form method easy enough if necessary:

\<% form\_for([@club, @address], :url =\>  
verify\_edit\_club\_address\_path(@club, @address), :method =\> :post) do |  
f| -%\>
