3

アセット パイプラインを把握したと思っていましたが、それ以上ではありません。

client.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;
      }
    }
  }
}

本番環境でプリコンパイルしようとするたびに、「file.png はプリコンパイルされていません」というエラーが表示され続けます。

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)

画像ファイルは app/assets/images ディレクトリにあり、public/assets ディレクトリに拡張指紋名で表示されます。

どんなアイデアでも役に立ちます。

4

1 に答える 1

1

あなたが望むのはこれだと思います:

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

または、clients.css.scss を client.css.scss.erb に変更して、次のようにします。

thead tr
  {
    background: image-url(<%= asset_path "list-view-header.png" %>) repeat-x;
  }
于 2011-11-08T18:46:50.210 に答える