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

陌路散爱 提交于 2019-12-11 09:46:07

问题


wrong number of arguments (2 for 1) Extracted source (around line #5):

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

I've tried:

<%= stylesheet_link_tag :all %> 

but I got:

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

What confused me most is that I run an app on my MAC OS with almost the same config except mysql&Gemfile and it works well, but when I turn to centos5 I got these errors!


回答1:


I had this problem too, and it turned out to be due to some code still targeting an older rails version, before the new asset pipeline work. Specifically, I had a redmine plugin using the method image_path with two arguments:

image_path('database_refresh.png', :plugin => 'redmine_rate')

This was no longer possible, and needed to be replaced with code that explicitly calculated the plugin specific path. I used code based on the wiki document at http://www.redmine.org/boards/3/topics/31445#Links-and-paths-to-plugin-assets

Note that this solution was for a problem I had with redmine, not rails, but could in fact be relevant.




回答2:


<%= stylesheet_link_tag    "application" %>

Should be fine. Rails has an assets pipeline to merges all the different stylesheets into one for the productive environment. I think it is an error in the assets pipeline.

Here is a good tutorial about this pipeline: http://railscasts.com/episodes/279-understanding-the-asset-pipeline

To possibly fix your error have a look at config/environments/production.rb and try to set this to true

config.assets.compile = true

Another problem might be the configuration in the application.css have you perhaps deleted the comments or added something?

/*
 * 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 .
*/

But these are just guesses... but I hope this leads you towards the solution of the problem.



来源:https://stackoverflow.com/questions/8431289/argumenterror-2-for-1rails3-1-0-stylesheet-link-tag-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!