Forum: Ruby on Rails Mailer layouts , how to link to a css file

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.
Kad K. (Guest)
on 2009-01-15 13:43
I can send html emails using the new layouts feature

using inline style, there is no problem to get a nice display..
but what if ?

i would like to link to a css file , .. which king of link ?  to
public/stylesheets/email.css

if there is any relative image in the css for a background url ?
like

#header {
   background: #ffcc00 url(../../../images/logo.png) no-repeat 2px;
}

thanks for you help ?
Hassan S. (Guest)
on 2009-01-15 15:35
(Received via mailing list)
On Thu, Jan 15, 2009 at 3:43 AM, Kad K.
<removed_email_address@domain.invalid> wrote:

> i would like to link to a css file , .. which king of link ?  to
> public/stylesheets/email.css

Nothing to do with RoR, but you need to provide absolute, complete
URLs, e.g. 'http://example.com/stylesheets/email.css'.

> if there is any relative image in the css for a background url ?

Same deal,

>   background: #ffcc00 url(http://example.com/images/logo.png) no-repeat 2px;

HTH,
--
Hassan S. ------------------------ removed_email_address@domain.invalid
Kad K. (Guest)
on 2009-01-15 15:50
Hassan S. wrote:
> On Thu, Jan 15, 2009 at 3:43 AM, Kad K.
> <removed_email_address@domain.invalid> wrote:
>
>> i would like to link to a css file , .. which king of link ?  to
>> public/stylesheets/email.css
>
> Nothing to do with RoR, but you need to provide absolute, complete
> URLs, e.g. 'http://example.com/stylesheets/email.css'.
>
>> if there is any relative image in the css for a background url ?
>
> Same deal,
>
>>   background: #ffcc00 url(http://example.com/images/logo.png) no-repeat 2px;
>
> HTH,
> --
> Hassan S. ------------------------ removed_email_address@domain.invalid

Thanks a lot ...  I'll stop my tests... (was trying various option)
;-)) !

btw: discovered a bug using multiparts with layout  ( the plain text get
the html source code..) with a nice trick to be inserted in the
environment.rb ...  in case someone reads this post

module ActionMailer
  class Base
    private
    def candidate_for_layout?(options)
      (!options[:file] || options[:file].content_type != 'text/plain')
&& !@template.send(:_exempt_from_layout?, default_template_name)
    end
  end
end

thanks again !
This topic is locked and can not be replied to.