如何使注册页面成为Devise中的根页面? [英] How to make Sign up page be root page in Devise?
本文介绍了如何使注册页面成为Devise中的根页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
devise_for:users do
rootdevise / registrations#new
end
资源:books
我要做的是使Devise注册页面成为用户的欢迎页面,如果他们没有登录,但如果他们登录他们将会去图书索引。现在它只是给我标准的Ruby on Rails:Welcome Aboard页面,就像Devise不存在一样。我该怎么做?
答案
https://github.com/plataformatec/devise/issues/2393
devise_for:users
devise_scope:user do
authenticated:user do
root:to => 'books#index',as::authenticated_root
end
unauthenticated:user do
root:to => 'devise / registrations#new',as::unauthenticated_root
end
end
解决方案
devise_for:users
devise_scope:user do
authenticated:user do
root:to => 'books#index'
end
unauthenticated:user do
root:to => 'devise / registrations#new',as::unauthenticated_root
end
end
I'm running on Rails 4.0.0 with Devise 3.1.0. My routes are setup like this:
devise_for :users do
root "devise/registrations#new"
end
resources :books
What I'm trying to do is make the Devise Sign Up Page be the Welcome Page for users if they haven't signed in but if their signed in they'll go to the Book Index. Right now it just gives me the standard Ruby on Rails:Welcome Aboard page as if Devise doesn't exist. How would I do this?
Answer
https://github.com/plataformatec/devise/issues/2393
devise_for :users
devise_scope :user do
authenticated :user do
root :to => 'books#index', as: :authenticated_root
end
unauthenticated :user do
root :to => 'devise/registrations#new', as: :unauthenticated_root
end
end
解决方案
devise_for :users
devise_scope :user do
authenticated :user do
root :to => 'books#index'
end
unauthenticated :user do
root :to => 'devise/registrations#new', as: :unauthenticated_root
end
end
这篇关于如何使注册页面成为Devise中的根页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文