3

我以为我已经弄清楚了资产管道,但现在没有了。

我有一个名为 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;
      }
    }
  }
}

每次我尝试在生产中预编译它时,我都会收到“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 更改为 clients.css.scss.erb 并执行以下操作:

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