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.
Ee0293412faca21e4ebf3326ed9d5f8c?d=identicon&s=25 Kad Kerforn (kadoudal)
on 2009-01-15 12: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 ?
Bee69cfed999cd13e3bff73d472a39ee?d=identicon&s=25 Hassan Schroeder (Guest)
on 2009-01-15 14:35
(Received via mailing list)
On Thu, Jan 15, 2009 at 3:43 AM, Kad Kerforn
<rails-mailing-list@andreas-s.net> 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 Schroeder ------------------------ hassan.schroeder@gmail.com
Ee0293412faca21e4ebf3326ed9d5f8c?d=identicon&s=25 Kad Kerforn (kadoudal)
on 2009-01-15 14:50
Hassan Schroeder wrote:
> On Thu, Jan 15, 2009 at 3:43 AM, Kad Kerforn
> <rails-mailing-list@andreas-s.net> 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 Schroeder ------------------------ hassan.schroeder@gmail.com

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.