私はこれを私のapplication.html.erbに持っています
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<%= stylesheet_link_tag "application","jquery.mobile-1.4.5" %>
<%= javascript_include_tag "application","jquery.mobile-1.4.5" %>
<%= csrf_meta_tags %>
<%= yield(:head) %>
</head>
私の main/index.html.erb ファイルには次のものがあります。
<%= content_for :head do %>
<style type="text/css">
body {
display: table;
position: relative;
width: 100%;
height: 100%;
background: url(/assets/main/background.jpg) no-repeat center center scroll;
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;
-o-background-size: cover;
}
.center-wrapper{
margin: 0 auto;
text-align: center;
vertical-align: middle;
}
.ui-page {
background: transparent;
}
.ui-content{
background: transparent;
}
</style>
<% end %>
これはルート URL であり、正しくロードされます。この後、vendors/index.html.erb などの他の URL に移動すると、content_for (main/index.html.erb) のために生成された css がクリアされません。
body で使用されている背景画像を変更して、vendors/index.html.erb に css を配置しようとしました。でも、反映されませんでした。main/index.html.erb の content_for のために生成された css をまだ使用しています。