2012-07-09 43 views
0

我在我的Rails應用程序中使用Devise gem進行身份驗證。我可以通過以Json請求格式傳遞數據來創建用戶,以從Titanium移動應用程序中設計Rails應用程序。 但是,當我嘗試設置登錄移動應用使用色器件,它顯示一個如下移動應用程序(Titanium)使用設計寶石認證的問題

{"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

我找到了解決辦法,我錯過了在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 

希望這將幫助一些路由信息的人:)