Ruby on rails RubyonRails-删除标题和侧栏管理员
如何隐藏标题和侧边栏管理员,仅用于注册页面?对于登录,当我运行此命令时,它会自动生成Ruby on rails RubyonRails-删除标题和侧栏管理员,ruby-on-rails,ruby,Ruby On Rails,Ruby,如何隐藏标题和侧边栏管理员,仅用于注册页面?对于登录,当我运行此命令时,它会自动生成railsg designe:views-users。注册页面怎么样 这是我的路线。rb: Rails.application.routes.draw do devise_for :users, controller: { sessions: "sessions/registrations" } get 'home/index' root
railsg designe:views-users
。注册页面怎么样
这是我的路线。rb
:
Rails.application.routes.draw do
devise_for :users, controller: {
sessions: "sessions/registrations"
}
get 'home/index'
root :to => 'home#index'
end
class ApplicationController < ActionController::Base
before_action :authenticate_user!
layout 'admin_lte_2'
end
和我的应用程序\u controller.rb
:
Rails.application.routes.draw do
devise_for :users, controller: {
sessions: "sessions/registrations"
}
get 'home/index'
root :to => 'home#index'
end
class ApplicationController < ActionController::Base
before_action :authenticate_user!
layout 'admin_lte_2'
end
class ApplicationController
我不知道您是如何将Desive与admin lte结合使用的,但我可以看到两种可能的解决方案
选择1
您可以为登录用户定义不同的路由:
devise_for :users
devise_scope :user do
authenticated :user do
root 'home#index', as: :authenticated_root
end
get 'user', to: 'devise/sessions#new'
end
未经验证的用户将被重定向到设计/会话#新建视图(或您选择的任何其他视图)
如果您希望为这些用户显示注册页面以外的其他内容,请添加未经验证的根目录:
unauthenticated do
root 'foo#bar', as: :unauthenticated_root
end
选择2
创建没有标题和侧边栏的自定义注册页面。我认为编辑Desive生成的视图比创建自定义布局更容易(我不知道这是否是一种好的做法)。
您可能会看到:
app/views/devise/registrations/new.html.erb
只需编辑它,它将适合您的需要
要为Desive创建自定义布局,请参见此处:
我希望有帮助