如何使注册页面成为设计中的根页面? [英] How to make Sign up page be root page in Devise?

查看:8
本文介绍了如何使注册页面成为设计中的根页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Rails 4.0.0 和 Devise 3.1.0 上运行.我的路线设置如下:

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

我想要做的是让 Devise 注册页面成为用户的欢迎页面,如果他们尚未登录,但如果他们登录,他们将转到图书索引.现在它只是给了我标准的 Ruby on Rails:Welcome Aboard 页面,就好像 Devise 不存在一样.我该怎么做?

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?

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

这篇关于如何使注册页面成为设计中的根页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆