2

When i open page background image showing, but after come back on the page image not showing up in chrome (in safari all - ok)

Use paperclip

In my view (some code on HAML + Rails):

#list-projects
 - @projects.each do |project|
  .project{:style => "background: url('#{project.photo.url(:preview_16x9)}') no-repeat ;"}

Get this html:

<div id="list-projects">
          <div class="project" style="background: url('/system/projects/photos/000/000/001/preview_16x9/franchi.jpg?1392386916') no-repeat ;">
            <a href="/projects/1"> </a>
            <div class="description">
              <h3>Shops number two</h3>
              <h4>Square —
              305      м<sup>2</sup>.</h4>
            </div>
          </div>
          <div class="project" style="background: url('/system/projects/photos/000/000/002/preview_16x9/franchi.jpg?1392310632') no-repeat ;">
            <a href="/projects/2"> </a>
            <div class="description">
              <h3>Shops number one</h3>
              <h4>Square —
              305      м<sup>2</sup>.</h4>
            </div>
          </div>

</div>

upd:

navigation generated by this code (rails, haml)

%nav#mainmenu
 %li{class: current_page?(root_path)    && 'active' }
  = link_to_unless_current 'Projetcs', root_path
 %li{class: current_page?(contacts_path) && 'active' }
  = link_to_unless_current 'Contacts', contacts_path
r3cha
  • 111
  • 1
  • 6
  • After disable turbolinks gem all work fine. why the turbolinks gem do this? – r3cha Feb 17 '14 at 22:28
  • Found this http://stackoverflow.com/questions/20051244/turbolinks-with-carrierwave-images-as-css-background-image – r3cha Feb 17 '14 at 22:32

1 Answers1

2

Solved by adding #{request.protocol}#{request.host_with_port}

#project{:style => "background: url('#{request.protocol}#{request.host_with_port}#{project.photo.url}') no-repeat ;"}<

It's turbolinks gem problem. thanks core2juan

Community
  • 1
  • 1
r3cha
  • 111
  • 1
  • 6