3

I thought I had the assets pipeline figured out, but not any more.

I have a stylesheet named clients.css.scss

.client
{

  .list_view
  {
    width: 650px;
    height: 500px;
    overflow: auto;

    table
    {
      width: 650px;
      border: solid 2px #999999;
      border-collapse: collapse;

      thead tr
      {
        background: image-url('list-view-header.png') repeat-x;
      }

      thead tr:first-child
      {
        background-image: none;
      }
    }
  }
}

Every time I try to precompile it in production I keep getting a "file.png isn't precompiled" error.

bundle exec  rake assets:precompile RAILS_ENV=production --trace
/usr/local/rvm/gems/ruby-1.9.2-p290@pm/gems/rack-1.3.4/lib/rack/backports/uri/common_192.rb:53: warning: already initialized constant WFKV_
** Invoke assets:precompile (first_time)
** Execute assets:precompile
/usr/local/rvm/gems/ruby-1.9.2-p290@pm/gems/rack-1.3.4/lib/rack/backports/uri/common_192.rb:53: warning: already initialized constant WFKV_
rake aborted!
list-view-header.png isn't precompiled
  (in /var/rails/pm.onlinetherapy.com/app/assets/stylesheets/clients.css.scss.erb)

Tasks: TOP => assets:precompile
(See full trace by running task with --trace)

The image file is in the app/assets/images directory and I can see it in the public/assets directory with the extended finger print name.

Any ideas would be helpful.

user229044
  • 232,980
  • 40
  • 330
  • 338
Russ Petersen
  • 765
  • 1
  • 9
  • 29

1 Answers1

1

I believe that what you want is this:

thead tr
  {
    background: image-url('/assets/list-view-header.png') repeat-x;
  }

Or you can change your clients.css.scss to clients.css.scss.erb and do this:

thead tr
  {
    background: image-url(<%= asset_path "list-view-header.png" %>) repeat-x;
  }
mikeborgh
  • 1,192
  • 11
  • 22
  • I tried this and the rake command got past this image. Thanks for that, but I can't figure out why this works when [http://guides.rubyonrails.org/asset_pipeline.html#coding-links-to-assets](http://guides.rubyonrails.org/asset_pipeline.html#coding-links-to-assets) indicates **image-url("rails.png")** becomes **url(/assets/rails.png)**. From that I would think /assets/list-view-header.png should not include the **`/assets/`**. Is there any explanation for this? I've been taught to take the guides.rubyonrails.org to be the bible for Ruby on Rails. – Russ Petersen Nov 08 '11 at 19:55
  • I've finally worked my way through the rake assets:precompile mess and it finished without any errors. BUT, now the images don't show up on the production website. Looking at the HTML shows `background: image-url('/assets/list-view-header.png') repeat-x;` without the fingerprint appended to the file name. I wouldn't call this a success. – Russ Petersen Nov 08 '11 at 23:48
  • I've tried renaming the file to clients.css.scss.erb and using asset_path `background: image-url(<%= asset_path "list-view-header.png" %>) repeat-x;` and this seems to work. Still don't know why the other methods don't work. – Russ Petersen Nov 09 '11 at 00:11
  • I'm frustrated by what appears to be changing rules in the rails 3.1 asset pipeline. At first `image-url('image.png')` worked in a style sheet. Now it has to be `image-url('<%= 'image.png' %>')` even though the documentation shows the first case should work. – Russ Petersen Nov 09 '11 at 00:21