在 Rails 应用程序中绕过 application.html.erb [英] bypass application.html.erb in Rails app

查看:44
本文介绍了在 Rails 应用程序中绕过 application.html.erb的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 application.html.erb 文件,它为我的应用程序中的每个页面(页眉、页脚等)设置布局,就像典型的 Rails 应用程序一样.

I have an application.html.erb file which sets out layout for every pages in my app (header, footer etc.) like a typical Rails app.

但是,我想要一个我不想使用此文件的登录页面.我应该如何绕过 application.html.erb?

However, I would like to have a landing page which I don't want to use this file. How should I bypass application.html.erb?

谢谢.

推荐答案

使用

render :layout => false

render :layout => 'whatever'

在你的行动中.如果您使用单独的 LandingController,您只需创建一个 app/views/layouts/landing.html.erb 它将被拾取,或者您可以通过

in your action. If you are using a separate LandingController you simply can create a app/views/layouts/landing.html.erb which will be picked up or you can override the layout via

class LandingController < ApplicationController
  layout 'whatever'
  ...
end

这篇关于在 Rails 应用程序中绕过 application.html.erb的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆