ArgumentError(2 for 1):Rails3.1.0<%= stylesheet_link_tag“application”%>

时间:2011-12-08 12:53:55

标签: ruby-on-rails-3.1

错误的参数数量(2对1) 提取的来源(第5行):

<html>
<head>
<title>Assets</title>
<%= stylesheet_link_tag 'application'%>
<%= javascript_include_tag %>
<%= csrf_meta_tags %>
</head>

我试过了:

<%= stylesheet_link_tag :all %> 

但我得到了:

<link href='assets/all.css' ...>

让我最困惑的是我在我的MAC OS上运行一个应用程序,除了mysql和Gemfile之外几乎相同的配置,它运行良好,但当我转向centos5时,我收到了这些错误!

2 个答案:

答案 0 :(得分:1)

我也遇到了这个问题,原来是由于在新资产管道工作之前,一些代码仍然针对较旧的rails版本。具体来说,我有一个redmine插件使用方法image_path,有两个参数:

image_path('database_refresh.png',:plugin =&gt;'redmine_rate')

这已不再可能,需要替换为明确计算插件特定路径的代码。我使用了基于http://www.redmine.org/boards/3/topics/31445#Links-and-paths-to-plugin-assets

的wiki文档的代码

请注意,此解决方案是针对我使用redmine而不是rails的问题,但实际上可能是相关的。

答案 1 :(得分:0)

<%= stylesheet_link_tag    "application" %>

应该没问题。 Rails有一个资产管道,可以将所有不同的样式表合并为一个用于生产环境的样式表。我认为这是资产管道中的一个错误。

这是关于此管道的一个很好的教程: http://railscasts.com/episodes/279-understanding-the-asset-pipeline

要修复错误,请查看config / environments / production.rb并尝试将其设置为true

config.assets.compile = true

另一个问题可能是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 .
*/

但这些只是猜测......但我希望这会引导您解决问题。

相关问题