我在我的Rails应用程序中使用Devise gem进行身份验证。我可以通过以Json请求格式传递数据来创建用户,以便从Titanium移动应用程序设计rails应用程序。 但是当我尝试在移动应用程序中设置登录以使用设计时,它会显示如下错误
{"error":"You need to sign in or sign up before continuing."}
我的代码如下所示
var regDetails = '{"email": "'+userNmTxt.value+'", "password": "'+passwordTxt.value+'"}';
var client = Titanium.Network.createHTTPClient({timeout: 5000});
client.open("POST", "http://10.100.85.43:3000/session/create");
client.setRequestHeader("Content-Type", "application/json");
client.send(regDetails);
client.onload = function(e)
{
alert('Logged in successfully' + this.responseText);
}
client.onerror = function(e)
{
alert('On error' + this.responseText);
}
我做错了什么?
答案 0 :(得分:0)
我找到了解决方案,我在routes.rb
文件
devise_scope :user do
match "/session/create" => "session#create" #, :via => [:get, :post]
match "/session/destroy" => "session#destroy" #, :via => [:get, :post]
match "/registration/create" => "registration#create" #, :via => [:get, :post]
end
希望这会有所帮助:)