设计 sign_in 页面未在 rails 4.2.1 中以单独的布局呈现
devise sign_in page is not rendering in a seperate layout in rails 4.2.1
我想为正在运行的设计签名设置单独的布局。
我在我的应用程序控制器中使用以下代码。
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_action :configure_permitted_parameters, if: :devise_controller?
layout :layout_by_resource
def after_sign_in_path_for(resource)
stored_location_for(resource) ||
if resource.is_a?(User)
new_applicant_response_url
else
homepage_admin_page_path
end
end
protected
def layout_by_resource
if devise_controller?
"layout_name_for_devise"
else
"application"
end
end
protected
def configure_permitted_parameters
devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:assessment_id, :name, :email, :password, :password_confirmation, :remember_me) }
devise_parameter_sanitizer.for(:sign_in) { |u| u.permit(:login, :email, :password, :remember_me) }
devise_parameter_sanitizer.for(:account_update) { |u| u.permit(:name, :email, :password, :password_confirmation, :current_password) }
end
end
并且我生成了设计视图并向设计登录页面添加了一些样式。
当我点击 devise/sign_in 时,我在终端中得到以下输出
Started GET "/admins/sign_in" for 127.0.0.1 at 2015-07-24 12:39:49 +0530
Processing by Devise::SessionsController#new as HTML
Rendered devise/shared/_links.html.erb (0.9ms)
Rendered devise/sessions/new.html.erb within layouts/layout_name_for_devise (6.9ms)
Completed 200 OK in 21ms (Views: 8.4ms | ActiveRecord: 1.0ms)
我正在为此设计登录操作正确获取布局。但是在那个布局设计中 sign_in 表单不渲染,只有布局在渲染。
您的布局可能没有在其中调用 yield
。
我想为正在运行的设计签名设置单独的布局。
我在我的应用程序控制器中使用以下代码。
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_action :configure_permitted_parameters, if: :devise_controller?
layout :layout_by_resource
def after_sign_in_path_for(resource)
stored_location_for(resource) ||
if resource.is_a?(User)
new_applicant_response_url
else
homepage_admin_page_path
end
end
protected
def layout_by_resource
if devise_controller?
"layout_name_for_devise"
else
"application"
end
end
protected
def configure_permitted_parameters
devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:assessment_id, :name, :email, :password, :password_confirmation, :remember_me) }
devise_parameter_sanitizer.for(:sign_in) { |u| u.permit(:login, :email, :password, :remember_me) }
devise_parameter_sanitizer.for(:account_update) { |u| u.permit(:name, :email, :password, :password_confirmation, :current_password) }
end
end
并且我生成了设计视图并向设计登录页面添加了一些样式。
当我点击 devise/sign_in 时,我在终端中得到以下输出
Started GET "/admins/sign_in" for 127.0.0.1 at 2015-07-24 12:39:49 +0530
Processing by Devise::SessionsController#new as HTML
Rendered devise/shared/_links.html.erb (0.9ms)
Rendered devise/sessions/new.html.erb within layouts/layout_name_for_devise (6.9ms)
Completed 200 OK in 21ms (Views: 8.4ms | ActiveRecord: 1.0ms)
我正在为此设计登录操作正确获取布局。但是在那个布局设计中 sign_in 表单不渲染,只有布局在渲染。
您的布局可能没有在其中调用 yield
。