如何在 Rails 3 中更改 Devise 的根控制器路径?
我有一个使用 Devise 的 Rails 3 应用程序。如何将设备的根控制器更改为应用程序根控制器之外的其他控制器。
在我的routes.rb 文件中,我将应用程序根设置为 root :to => 'home#index'
因此 http://app.com/users/sign_in 将调用设计的形式不是我想要的。
我在routes.rb中也有以下内容(这是我想要设计使用的路线):
scope :module => 'control' do
constraints :subdomain => 'control' do
resources :offers
root :to => 'offers#index'
end
end
如何指出设计使用上述路径(control.app.com),以便用户登录位于< a href="http://control.app.com/users/sign_in" rel="nofollow">http://control.app.com/users/sign_in?
谢谢!
蒂姆
I have a Rails 3 app that uses Devise. How do I go about changing devise's root controller to something other than the application's root controller.
In my routes.rb file, I have the applications root set as root :to => 'home#index'
so http://app.com/users/sign_in will call up the devise form which is not what I want.
I also have the following in routes.rb (this is the route that I want devise to use):
scope :module => 'control' do
constraints :subdomain => 'control' do
resources :offers
root :to => 'offers#index'
end
end
How can I point devise to use the above path (control.app.com) so that the user sign in would be located at http://control.app.com/users/sign_in?
Thanks!
Tim
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我找到了解决方案。我在范围内添加了
devise_for
,如下所示:您需要添加
:module =>; 'devise'
因为模块已更改为名称空间的名称,因此您必须将其设置回 'devise'。现在我可以使用control
子域访问所有设计操作(例如 control.app.com/users/sign_in、control.app.com/users/sign_up 等)I've found the solution. I added
devise_for
inside the scope as so:You need to add
:module => 'devise'
because the module is changed to the namespace's name, so you have to set it back to 'devise'. Now I can access all the devise actions with thecontrol
subdomain (ex. control.app.com/users/sign_in, control.app.com/users/sign_up, etc)也许您在定义登录页面的根路由并在其中传递子域时需要使用 devise_scope ?只是一个猜测。
https://github.com/plataformatec/devise/blob/ 中的“配置路由” master/README.rdoc 可能会有所帮助。
Maybe you need to use
devise_scope
when defining your root route for your sign-in page and pass your subdomain in there? Just a guess."Configuring routes" in https://github.com/plataformatec/devise/blob/master/README.rdoc may be of some help.