ruby on rails - show first image in css definition? -


i have inline css/ haml

:css               .testimonials{         background: url('/assets/#{@house.slug}.jpg');         padding: 80px 0;          background-size: cover;         -webkit-background-size: cover;         -moz-background-size: cover;         -o-background-size: cover;         background-size: cover;         background-attachment: fixed;/* ie fix */       } 

this shows image assets folder related house in parallax scrolling website.

i use carrierwave manage images houses, , want show first image in css background definition don't have upload image assets folder anymore.

- @house.attachments.each.first |a|     = image_tag(a.file.url(:thumb)) 

how can place loop in inline css definition?

thanks..remco

by using style option

image_tag a.file.url(:thumb), :style => "background: url(a.file.url(:thumb))" 

even no need image_tag div add style option background image


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -