Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/52.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
Ruby on rails 如何消除rails erb文件中的重复代码_Ruby On Rails_Erb_Railstutorial.org - Fatal编程技术网

Ruby on rails 如何消除rails erb文件中的重复代码

Ruby on rails 如何消除rails erb文件中的重复代码,ruby-on-rails,erb,railstutorial.org,Ruby On Rails,Erb,Railstutorial.org,我该怎么做才能消除正在发生的双重代码 在about.html.erb中,我有以下代码: <!DOCTYPE html> <html> <head> <title>Ruby on Rails Tutorial Sample App | <%= @title %></title> </head> <body> <h1>Pages#about</h1> <

我该怎么做才能消除正在发生的双重代码

在about.html.erb中,我有以下代码:

<!DOCTYPE html>
<html>
<head>
    <title>Ruby on Rails Tutorial Sample App | <%= @title %></title>
</head>
<body>
    <h1>Pages#about</h1>
    <p>Find me in app/views/pages/about.html.erb</p>
</body>
</html>

RubyonRails教程示例应用程序|
关于
在app/views/pages/about.html.erb中查找我

在本地主机的浏览器中:3000/页/大约

<!DOCTYPE html>
<html>
<head>
  <title>SampleApp</title>
  <link href="/stylesheets/application.css" media="all" rel="stylesheet" type="text/css" />
  <script src="/javascripts/application.js" type="text/javascript"></script>
  <meta content="authenticity_token" name="csrf-param" />
<meta content="ra/NXpqBo1ccudzQ2HGHoo3OrZB2bLX732MQl+EJHU4=" name="csrf-token" />
</head>
<body>

<!DOCTYPE html>
<html>
<head>
    <title>Ruby on Rails Tutorial Sample App | About</title>
</head>
<body>
    <h1>Pages#about</h1>
    <p>Find me in app/views/pages/about.html.erb</p>
</body>
</html>

</body>
</html>

样本应用
Ruby on Rails教程示例应用程序|关于
关于
在app/views/pages/about.html.erb中查找我


副本是app/views/layouts/application.html的一部分。erb

默认情况下,使用布局是应用程序布局,您只需要内容。谢谢你的评论。我将如何执行你给我的建议。在about.html.erb中只保留“Pages#about在app/views/Pages/about.html.erb中查找我”我得到了它。非常感谢。副本是app/views/layouts/application.html.erb的一部分。我要用它来更干燥。