Ruby on rails 4 在布局视图中使用设计标志
我有两个布局Ruby on rails 4 在布局视图中使用设计标志,ruby-on-rails-4,devise,Ruby On Rails 4,Devise,我有两个布局 application.html.erb login.html.erb 我使用设计。 在application_controller.rb中,我编写以下代码: protect_from_forgery with: :exception layout :another_by_method private def another_by_method if user_signed_in? "application" else "l
protect_from_forgery with: :exception
layout :another_by_method
private
def another_by_method
if user_signed_in?
"application"
else
"login"
end
end
根据此代码,如果用户未登录,则显示login.html.erb。
我想在login.html.erb的表单中使用designe sign_,但由于这段代码,所有页面都重定向到login.html。
我也使用下面的代码
<%= render partial: "devise/sessions/new"%>
有什么想法吗 您正在尝试渲染部分,但
设计/sessions/new
不是部分
不管怎样,您是否已使用rails-generate-designe:views
生成视图?如果是,您可以这样做:
= render file: 'devise/sessions/new'
使用
文件
而不是部分
,但您将需要Desive提供的所有变量,如资源、资源名称或Desive映射。登录没问题,但当我注销时,我会得到[NameError in Home#index]。主页是根页面,如果用户登录,该页面将重定向到仪表板。有什么问题?!好的,我认为您需要添加一个关于注销错误的新问题,因为这是关于登录的问题。
= render file: 'devise/sessions/new'