How do I pass an instance variable from my controller to my assets stylesheet?
Can I do something like this
preview_controller.rb
def show
@design = Design.first
end
and my assets file is
preview.css.scss.erb
body{
background-image: url('<%= @design.image_url.to_s %>');
}
You can’t do this (the assets are pre-compiled and do no have access to variables from the request). You could have this in your HTML page itself:
It would achieve the same end result.