Ashley Moran
2006-Aug-18 10:58 UTC
[Rails] Including CSS from a stylesheet file in a an e-mail
How can I include the contents of the file /public/stylesheets/print.css in an RHTML page for ActionMailer? Because there is no controller or session, none of the usual tricks work. Do you have to use basic file IO or there some convenience method I haven''t seen? Thanks Ashley -- "If you do it the stupid way, you will have to do it again" - Gregory Chudnovsky
Chris Hall
2006-Aug-18 11:19 UTC
[Rails] Including CSS from a stylesheet file in a an e-mail
you''ll most likely have to have the css either ''hard-coded'' in the resulting html within style tags or make sure the link reference is a full URL, ie, http://www.yoursite.com/stylesheets/print.css and URI is publically accessible. <style type="text/css"> ... </style> or <link ref="stylesheet" type="text/css" href="http://www.yoursite.com/stylesheets/print.css"/> using stylesheet_link_tag won''t do it as it does not include the hostname in the href attribute. On 8/18/06, Ashley Moran <work@ashleymoran.me.uk> wrote:> How can I include the contents of the file /public/stylesheets/print.css in an > RHTML page for ActionMailer? Because there is no controller or session, none > of the usual tricks work. > > Do you have to use basic file IO or there some convenience method I haven''t > seen? > > Thanks > Ashley > > -- > "If you do it the stupid way, you will have to do it again" > - Gregory Chudnovsky > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Ashley Moran
2006-Aug-18 14:49 UTC
[Rails] Including CSS from a stylesheet file in a an e-mail
On Friday 18 August 2006 12:19, Chris Hall wrote:> you''ll most likely have to have the css either ''hard-coded'' in the > resulting html within style tags or make sure the link reference is a > full URL, ie, http://www.yoursite.com/stylesheets/print.css and URI is > publically accessible. > > <style type="text/css"> > ... > </style> > > or > > <link ref="stylesheet" type="text/css" > href="http://www.yoursite.com/stylesheets/print.css"/> > > using stylesheet_link_tag won''t do it as it does not include the > hostname in the href attribute.Thanks Eventually we got it working with <%= IO.read("public/stylesheets/print.css") %> I was hoping there''d be a helper function or something to handle this but I guess the solution is pretty simple. Ashley -- "If you do it the stupid way, you will have to do it again" - Gregory Chudnovsky