stylesheet_link_tag

Hi,

I have the following, very simple, simple layout -

<html>   <head>     <%= title_tag %>   <%= stylesheet_link_tag %>   </head>

  <body>     <h1>Main Title</h1>     <P>Up until this point, the HTML's coming from the application layout.</p>     <%= @content_for_layout %>   </body>

</html>

which renders fine but without a stylesheet tag in the HTML. If I change the stylesheet tag to -   <%= stylesheet_link_tag "main", "blog", :media => "all" %> or even   <%= stylesheet_link_tag "main" %>

- then I get an exception raised -

wrong number of arguments (2 for 0)

I have a number of options for working around this, but I'd like to understand where I'm going wrong. Anyone care to enlighten me? TIA.

Gordon

hey man,

I just pulled this from my working template: <%= stylesheet_link_tag 'style' %>

the only difference I can see is you used double quotes, I'm on singles, see if that helps. I guess its not rendering a style tag because you haven't passed it any parameters like name etc...

Im still learning myself so I may be wrong, but you never know!

cheers, Lee

Nope, still getting the exception. I've got a stack trace which points me at the method which is throwing the exception. I guess I'm going to have to dig around in the code and see if I can work it out.

Gordon

Nope, still getting the exception. I've got a stack trace which points me at the method which is throwing the exception. I guess I'm going to have to dig around in the code and see if I can work it out.

Do you get the same exception when <%= title_tag %> is removed?

Regards

Hi,

That's REALLY odd.

What happens if you have nothing but the stylesheet link tag in your
layout?

Julian.

Learn Ruby on Rails! Check out the FREE VIDS (for a limited time)
VIDEO #4 coming soon! http://sensei.zenunit.com/

I see where you're going with this. Is it my dodgy helper method? :). Unfortunately not, I get the same error.

Gordon

If I have a layout with only this -

<%= stylesheet_tag %>

, then I get this rendered -

<link rel="stylesheet" href="stylesheets/main.css" type="text/css" />

OTOH, if I have a layout with only this line -

<%= stylesheet_tag 'main' %>,

then I get a "wrong number of arguments" exception.

Gordon

Gordon Robertson wrote:

which renders fine but without a stylesheet tag in the HTML. If I change the stylesheet tag to -   <%= stylesheet_link_tag "main", "blog", :media => "all" %> or even   <%= stylesheet_link_tag "main" %>

- then I get an exception raised -

wrong number of arguments (2 for 0)

I have a number of options for working around this, but I'd like to understand where I'm going wrong. Anyone care to enlighten me? TIA.

stylesheet_link_tag with no parameters appears to be an error according to the comments in the helper method that handles this tag. Your last option should work, though (with just "main" as a parameter). You *do* have a css file called "main.css" in your public/stylesheets directory, right?

You could also try: <%= stylesheet_link_tag :all %>

...which is supposed to make style link tags for all the .css files in your stylesheets directory.

  - Aaron

Yep, there's a main.css in public/stylesheets.

I just tried it with :all. Got the same exception.

Gordon

Ah, cracked it. I had a helper method named stylesheet_tag in application_helper.rb. This was clashing with the identically named method in action_view/helpers/asset_tag_helper.rb.

Gordon

Gordon Robertson wrote: