如何使注册页面成为设计中的根页面?

2024-02-15

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

devise_for :users do
  root "devise/registrations#new"
end

resources :books

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


Answer

https://github.com/plataformatec/devise/issues/2393 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
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何使注册页面成为设计中的根页面? 的相关文章

随机推荐