I have a background image on which I cannot stay on one page. I made a welcome controller with one home view to display it. I will also pre-combine my assets. The background looks just fine, but my goal is to just show the background image in my home.html.erb view.
Welcome /home.html.erb:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<%= I18n.locale || 'en' %>" lang="<%= I18n.locale || 'en'%>"> <body class="container"> <h1>title</h1> </body> </html>
Welcome controller:
class WelcomeController < ApplicationController def home end end
style sheets /welcome.css.scss:
body { background: { image: asset-url("image.jpg"); } }
and in my application layout there is the following:
<head> <%= stylesheet_link_tag "welcome" if controller_name == "welcome" %> </head>
and in config / initializers / assets.rb:
Rails.application.config.assets.version = '1.0' Rails.application.config.assets.precompile += %w( welcome.css )
css ruby ruby-on-rails sass ruby-on-rails-4
dobsoft
source share