在Rails中安装sinatra app的Devise认证 [英] Devise authentication for sinatra app mounted in Rails
本文介绍了在Rails中安装sinatra app的Devise认证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 -
- Rails 3.2.2
- Ruby 1.9.3
-
- Devise 2.0.4
我的路由文件如下所示:
my route file looks like this:
Foo::Application.routes.draw do
devise_for :admins
root :to => "home#index"
authenticate :admin do
mount Simple::App, at: '/simple'
end
end
访问/简单需要验证。
access under /simple needs to be authenticated.
但是,如果没有登录,则访问/ simple / *将重定向到/ simple / admin / sign_in而不是只创建一个重定向循环的/ admin / sign_in。
However if not signed in , access to /simple/* will be redirect to /simple/admin/sign_in instead of just /admin/sign_in which creates a redirect loop.
我需要创建一个自定义的fail_app来更正此行为吗?
Do I need to create a custom failure_app to correct this behavior?
谢谢!
推荐答案
Foo::Application.routes.draw do
devise_for(:admins)
root(to: 'home#index')
match('/simple/admins/sign_in' => redirect('/admins/sign_in'))
authenticate(:admin) do
mount(Simple::App, at: 'simple')
end
end
这篇关于在Rails中安装sinatra app的Devise认证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文