Ruby on rails 4 仪表板的单独模板
我需要为仪表板使用单独的模板。因此 加载完全不同的模板 因此,我在layouts/dashboard_template.html.erb下创建了一个模板 我的仪表盘滚轮Ruby on rails 4 仪表板的单独模板,ruby-on-rails-4,Ruby On Rails 4,我需要为仪表板使用单独的模板。因此 加载完全不同的模板 因此,我在layouts/dashboard_template.html.erb下创建了一个模板 我的仪表盘滚轮 class DashboardController < ApplicationController def index render template: 'layouts/dashboard_template.html.erb' end end 但是,它会在application.html.erb
class DashboardController < ApplicationController
def index
render template: 'layouts/dashboard_template.html.erb'
end
end
但是,它会在application.html.erb中加载模板!我不知道怎么修。希望这是清楚的。请帮助。在您的仪表板控制器中使用
class DashboardController < ApplicationController
layout :set_layout, only: [:index]
def index
# do your stuff
end
def set_layout
"layout_file_name" || 'application'
end
end
class仪表板控制器
这将加载布局(如果存在其他主应用程序布局)谢谢,它是固定的:)
class DashboardController < ApplicationController
layout :set_layout, only: [:index]
def index
# do your stuff
end
def set_layout
"layout_file_name" || 'application'
end
end