Only get, put, and delete requests are allowed

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. :frowning: Thanks for your time!

~Dustin T.

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

On Jul 31, 9:36 am, Frederick C. [email protected]
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.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs