Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何防止特定html页面获得默认样式?_Html_Ruby On Rails - Fatal编程技术网

如何防止特定html页面获得默认样式?

如何防止特定html页面获得默认样式?,html,ruby-on-rails,Html,Ruby On Rails,我不熟悉HTML和Ruby,我创建了一个应用程序,我将所有样式都放在application.HTML.ERB文件中。它包含页眉页脚样式,自动应用于我的项目中的所有HTML文件。现在我想删除show.HTML页面的默认样式。而且我不需要show.HTML页面的任何页眉和页脚。我怎样才能做到这一点请任何人帮助我。 application.HTML.ERB <!DOCTYPE html> <html> <head> <title>Contact&

我不熟悉HTML和Ruby,我创建了一个应用程序,我将所有样式都放在application.HTML.ERB文件中。它包含页眉页脚样式,自动应用于我的项目中的所有HTML文件。现在我想删除show.HTML页面的默认样式。而且我不需要show.HTML页面的任何页眉和页脚。我怎样才能做到这一点请任何人帮助我。 application.HTML.ERB

 <!DOCTYPE html>
 <html>
 <head>
 <title>Contact</title>
  <%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track' => true %>
  <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
  <%= csrf_meta_tags %>
  <header>
     <div class="al" >
  <div class = "logo">
     <img src="/data/contact.png" width="50px" height = "50px"/>
     </div>
     <div class="con">
     Contact Book
     </div>
        </div>
      </header>

   </head>
   <body>
    <%= yield %>
  </body>
  <footer>
  <p align="center"> All text and design @2014 Report Bee Edusys Ltd.
  </p>
   </footer>
  </html>

若你们想在控制器中为一个动作使用单独的布局,否则我们可以在呈现模板时发送布局

试试这个

 layout nil  # no layout default is application
 layout 'application', :except => :show  # inheriting application except one action "show"

您应该在application.html.erb文件旁边创建一个不同的布局文件,然后在操作中指定该布局,如下所示:

render :action => "show", :layout => "my_new_layout"
如果在两个布局中都有需要的共享部分,则可以将它们移动到部分中,然后在每个布局中渲染部分


请参见添加布局错误,在该控制器中,您不希望默认样式是您的显示模板一个完整的html文档,即带有声明、a和a?如果是这样,那么:layout=>false将适用于您。如果没有,那么你需要使用不同的布局,而不是没有布局。当你为你的意图添加解释时,这将对OP和其他访问者更有帮助。谢谢