Hey everyone,
I have been using Ruby on Rails for a few months now (I come from a
php / Java/J2EE background) and have been LOVING it. I do have one
question regarding XML output and the SessionsController#create method
that is generated by the restful authentication plugin.
I added the following code to the create method:
#if login is successful
respond_to do |format|
format.html { redirect_back_or_default('/')}# index.html.erb
format.xml { render :xml => self.current_user }
end
#if login is not successful
respond_to do |format|
format.html { render :action => 'new'}# index.html.erb
format.xml { response.status_code.should == 401 }
end
When I try to test this like this:
http://localhost:3000/sessions/create?login=myuser&password=mypassword
I am able to login successfully. If I add .xml to the end of create
like this:
http://localhost:3000/sessions/create.xml?login=myuser&password=mypassword
I get the following exception: No route matches “/sessions/create.xml”
with {:method=>:get}. My routes.rb is pretty generic (has all of the
restful authentication mappings) and I haven’t touched it. Any ideas
as to what I’m doing wrong? How can I log in to my site from a 3rd
party client?
Thanks,
Mark Dinstuhl