Forum: Ruby on Rails print.css not being picked up

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Max W. (Guest)
on 2009-05-20 17:06
I'm working on a new app and i can't get print.css to work properly.  I
can't work out why.  I've tried referencing it with the rails
stylesheet_link_tag helper and by hard-coding the link.  Neither work -
when i go to print-preview (in firefox) it's not using the right

The file, print.css, is in public/stylesheets.  I've tried this:

<%= stylesheet_link_tag "print", :media => "print" %>

which generates:

<link href="/stylesheets/print.css?1242817476" media="print"
rel="stylesheet" type="text/css" />

and i've tried this:

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

which of course just stays as it is.  Neither work.  is there something
special i have to do with print stylesheets in rails?

Colin L. (Guest)
on 2009-05-20 17:21
(Received via mailing list)
I have
<%= stylesheet_link_tag 'print', :media => :print %>
which seems to generate the same link as you have and it works fine in

Have you tried temporarily removing your standard stylesheet and
it with a renamed version of print.css to make sure it is not a problem
the contents?


2009/5/20 Max W. <removed_email_address@domain.invalid>
Max W. (Guest)
on 2009-05-20 19:41
Thanks, colin, i figured it out.  The problem was that the main
stylesheet, style.css was also being used for printing, so i needed to
change the link for the main stylesheet to have media="screen, print".
So, it was nothing to do with the link to print.css at all.

So, now my links look like this:

    <%= stylesheet_link_tag "style", "incomplete", :media => "screen,
print" %>
    <%= stylesheet_link_tag "print", :media => "print" %>

and it's all good.

This topic is locked and can not be replied to.