【问题标题】:Rails 3.1 Asset Pipeline Precompiling fails with asset_path wrong argumentsRails 3.1 资产管道预编译失败,asset_path 参数错误
【发布时间】:2012-05-01 21:59:00
【问题描述】:

处理 Rails 3.1 资产管道并失败的第一天!

这是资产抛出的一长串错误中的最新一个:在生产机器上预编译:

wrong number of arguments (1 for 2) for 'asset_path'

这发生在 application.css 文件上(我认为这是它尝试的第一个文件)。

这是我的application.css的内容

/*
 * This is a manifest file that'll automatically include all the stylesheets available in this directory
 * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
 * the top of the compiled file, but it's generally better to create a new file per style scope.
 *= require_self
 *= require_tree . 
*/

.account-badge
{
    background-color: #B94A48 !important
}

.centered {
    float: none;
    margin-left: auto;
    margin-right: auto;
}

.container[role="main"] {
    padding-bottom: 300px;
}

.page-footer {
    border-top: 1px solid #EEEEEE;
    padding-top: 17px;
}

我在一个全新的应用程序中使用twitter-bootstrap-rails 可能很重要(不是升级)

【问题讨论】:

  • 你的 .css 文件中对asset_path 的调用令人讨厌,在你的 .css 文件中找到所有 'asset_path' 调用并发布它们
  • 很奇怪,我遇到了同样的错误。 asset-path 需要 2 个参数,但第二个参数是什么。 image 有效,"yes" 也有效,这是在哪里使用的?查看 github rails/sass-rails,它显示了 1 个参数 github.com/rails/sass-rails/…

标签: ruby-on-rails-3.1 twitter-bootstrap asset-pipeline


【解决方案1】:

查看您的 bootstrap_and_overrides.css.less 文件,该文件已包含在您的 application.css 文件的链轮 (*= require_tree) 中。

我猜错误是通过包含@iconSpritePath@iconWhiteSpritePath 来定位的。

编辑: 该方法需要两个参数:

asset-url("rails.png", image)  # becomes url(/assets/rails.png)
asset-path("rails.png", image) # becomes "/assets/rails.png"

希望对你有帮助

【讨论】:

  • 我想这就是原因,因为它包含您所指的内容。然而奇怪的一点是错误状态asset_path需要2个参数并且只有1个。我的应用程序中的所有asset_path实例都有1个参数,我不知道第二个参数应该是什么,因为这个函数只接受一个参数。
猜你喜欢
  • 2020-11-17
  • 2012-04-02
  • 2012-05-20
  • 1970-01-01
  • 2013-05-08
  • 1970-01-01
  • 1970-01-01
  • 2023-03-31
  • 1970-01-01
相关资源
最近更新 更多