I am trying to make only my index action render a stylesheet/background image, but for some reason the background image is appearing on all the other pages as well. My welcome controller is handling all of this. The layout file is called background.css.scss. Here is my welcome controller:
class WelcomeController < ApplicationController
layout :resolve_layout
def index
end
def show
end
def about
end
def testimonials
end
private
def resolve_layout
case action_name
when "index"
"background.css.scss"
else
"application"
end
end
end
Here is background.css.scss stylesheet:
body {
width: 100%;
background: {
image: asset-url("sampleimage.png");
repeat: no-repeat;
size: 100% auto;
}
}
index view:
background-image: url(<%= asset_path 'sampleimage.jpg' %>)