Rails 3.1资产管道预编译失败,asset_path参数错误。

4

第一天处理Rails 3.1资源管道就遇到了挫折!

以下是在生产机器上通过assets:precompile抛出的最新错误之一:

asset_path函数参数数量错误(应为2个,实际为1个)

这会发生在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' 调用并将它们发布。 - RadBrad
非常奇怪,我得到了相同的错误。asset-path需要2个参数,但第二个参数是什么。image可以工作,也可以使用"yes",这在哪里使用?查看github rails/sass-rails,它显示1个参数https://github.com/rails/sass-rails/search?utf8=%E2%9C%93&q=asset-path - Chemist
1个回答

3
请查看您的bootstrap_and_overrides.css.less文件,它是由您的application.css文件中的sprockets (*= 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 个参数,我不知道这第二个参数应该是什么,因为这个函数只接受一个参数。 - Khash

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接