Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rails 4 - wrong number of arguments (2 for 1) - stylesheet_link_tag and javascript_include_tag

I am getting the following error in my rails app when I run it locally:

ActionView::Template::Error (wrong number of arguments (2 for 1)):
     8:         %link{href: "/assets/favico.png", rel: "icon"}/
     9:         %link{href: "https://fonts.googleapis.com/css?family=Open+Sans:400,700", rel: "stylesheet", type: "text/css"}/
    10:         = stylesheet_link_tag "application", :media => "all" 
    11:         = javascript_include_tag "application"
    12:         = csrf_meta_tags
    13:         = yield(:head)
  app/views/layouts/application.html.haml:10:in `_app_views_layouts_application_html_haml___410024948890833714_70223805533300'

I have deployed the app on heroku and there are no issues. This issue occurred recently after I updated from rails3 to rails 4.

Instead of using the helpers, adding the tags manually works:

%link{href: "/assets/application.css", media: "screen", rel: "stylesheet"}/
%script{src: "/assets/application.js"}
like image 414
Jeff Tsui Avatar asked Apr 28 '14 01:04

Jeff Tsui


2 Answers

i'm assuming you are using sprockets 2.12.0, if that's the case, downgrade it to 2.11.0 as per https://github.com/sstephenson/sprockets/issues/540

like image 98
mountriv99 Avatar answered Oct 20 '22 20:10

mountriv99


I've found that the updated gems, which have in their instructions to change application.css to application.css.scss, won't recognize 'application' as a parameter for a scss file for stylesheet_link_tag. You need to change:

<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>

to this:

<%= stylesheet_link_tag 'application.css.scss', media: 'all', 'data-turbolinks-track' => true %>

This will allow you to work with the latest gems.

like image 25
6ft Dan Avatar answered Oct 20 '22 21:10

6ft Dan