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.