# Only get, put, and delete requests are allowed

**URL:** <https://www.ruby-forum.com/t/only-get-put-and-delete-requests-are-allowed/144634>\
**Category:** Rails\
**Created:** [July 31, 2008, 5:22pm UTC](https://www.ruby-forum.com/t/only-get-put-and-delete-requests-are-allowed/144634 "2008-07-31T17:22:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tinney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/a88e4f/32.png) [@tinney](https://www.ruby-forum.com/u/tinney)\
**Post date:** [July 31, 2008, 5:22pm UTC](https://www.ruby-forum.com/t/only-get-put-and-delete-requests-are-allowed/144634/1 "2008-07-31T17:22:28Z")

</div>

Greetings,

I’m running into an odd problem here. Everything was working fine  
until I started playing with my application this morning. It seems  
that when I try to use my login action, I’m instead given this error.

Only get, put, and delete requests are allowed

This happens only after I submit the form. The login page is displayed  
fine when it’s displayed using the GET method. Here is my controller  
code:

def login  
session[:member\_id] = nil  
if request.post?  
member = Member.authenticate(params[:username],  
params[:password])  
if member  
session[:member\_id] = member.id  
flash[:notice] = “You have successfully logged in!”  
redirect\_to stories\_path  
else  
flash.now[:notice] = “Invalid username/password combination”  
end  
end  
end

None of the code runs from within the ‘if request.post?’ block. I  
removed the code and simply added a redirect\_to to see what would  
happen, and the error still persists. At the bottom of the error page,  
it says:

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

Is there a way to edit this to allow POST as well?

I’ve read on the Internet that moving your route high in the file will  
help, it didn’t. My rout looks like:

map.resources :members, :collection =\> { :login =\> :get, :logout  
=\> :get }

From day one, I’ve had this error message pop up often. It seemed to  
do so after editing my routes. A simple reboot of my server resolved  
the problem on these occasions - it’s not helping here.

Any help would be appreciated. I’ve already played with this for a few  
hours with no luck. ☹ Thanks for your time!

~Dustin T.

---

<div class="post-metadata">

**Author:** ![tinney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/a88e4f/32.png) [@tinney](https://www.ruby-forum.com/u/tinney)\
**Post date:** [July 31, 2008, 5:37pm UTC](https://www.ruby-forum.com/t/only-get-put-and-delete-requests-are-allowed/144634/2 "2008-07-31T17:37:44Z")

</div>

On 31 Jul 2008, at 16:21, Dustin T. wrote:

> Is there a way to edit this to allow POST as well?
> 
> I’ve read on the Internet that moving your route high in the file will  
> help, it didn’t. My rout looks like:
> 
> map.resources :members, :collection =\> { :login =\> :get, :logout  
> =\> :get }

try :login =\> :any  
You’ve said that login had to be a get, but your’re doing a post.

Fred

---

<div class="post-metadata">

**Author:** ![tinney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/a88e4f/32.png) [@tinney](https://www.ruby-forum.com/u/tinney)\
**Post date:** [July 31, 2008, 6:06pm UTC](https://www.ruby-forum.com/t/only-get-put-and-delete-requests-are-allowed/144634/3 "2008-07-31T18:06:30Z")

</div>

On Jul 31, 9:36 am, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> try :login =\> :any

That did the trick. I wonder why it has been working all this time  
with :get instead of :any. That’s very peculiar!

> Fred

Thank you very much for your help!

~Dustin T.
