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

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
73c04e9ef9ca435c5b19a2e765ae6d20?d=identicon&s=25 Max Williams (max-williams)
on 2009-05-20 15: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
styling.

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?

thanks
max
5f94b9b346c2aa648a80bc259978e5bc?d=identicon&s=25 Colin Law (Guest)
on 2009-05-20 15: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
FF
3.0.10

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

Colin

2009/5/20 Max Williams <rails-mailing-list@andreas-s.net>
73c04e9ef9ca435c5b19a2e765ae6d20?d=identicon&s=25 Max Williams (max-williams)
on 2009-05-20 17: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.

cheers
max
This topic is locked and can not be replied to.