2012-06-25 38 views
0

我正在使用rails 3.2并为移动应用程序使用jquery mobile和handlebar。我正在尝试使用API​​调用编写注销功能。在Rails API调用中设计注销

在我的lib/extras/api/users.rb 我正在尝试做devise的注销功能。

如何写

现在我写的像

resource :users do 
     delete '/sign_out' do 
      authenticate! 
      user = User.find(params[:id]) rescue not_found 
      # What to write here to signout the user 
      end 
end 

回答

0

您可以使用沃登(设计使用它进行认证),以注销用户首先指定一个辅助方法,它会给你的监狱长对象:

def warden 
    env['warden'] 
end 

,然后从API,您可以访问助手和应用以下方法就可以了,以注销用户:

warden.logout