Rails web service not returning required response
I am newbie to rails and currently trying to build a REST api on Rails.I am trying to connect to the rest web service from my android app. This is the controller code that i am routing the request to.
class SessionsController < ApplicationController
def create
user = User.authenticate(params[:userid],
params[:password])
if user.nil?
message="Invalid Username/Password"
return message
else
sessionId=make_sessionId
return sessionId
end
end
def destroy
end
end
I am trying to hit the create action in the SessionController.The problem is that the response i get is the html of the view whereas what i am looking forward to is the 'message or the 'sessionId' from the controller.I deleted the view files after which i am getting the html with exceptions inside it.
Can someone let me know what i should here to get the response from the 开发者_StackOverflow中文版controller rather than returning the html inside the view at the client.?
If you have no render in your Controller, then rails will use the view related to the action name. Try "render :text => message" for example. I hope I understood your question correctly.
精彩评论