I have a div which have dynamic background based on user-input, so I want to load the background directly from erb file so when I type
<div class="desk" style="background:url(myphoto.png);">
It doesn’t work, although it work if I typed this line into css file
so any suggestions what’s going on here?
Path is wrong it should be prefixed with “/assets/”. You should use asset_path method. Without that additional problems will occur on production when md5 hash will be added at the end of filename. Try this:
More information about that can be found in Rails Guides