English 中文(简体)
铁路3 全球承载人包容
原标题:Rails3 Global Header Inclusion

I ve got a number of Actionmailer groups that sent out a number of emails.... 我想从全球范围包括从这些铁路机中发送的每封电子邮件的负责人:

此处采用一种手法包括:

class GeneralNotification < ActionMailer::Base

    def test_email(emails)
        subject "Welcome to my email!"
        recipients "somebody@somewhere.com"
        from "chad@awesome.com"

        headers(
            "X-SMTPAPI" =>  {"category": "Test Category"} 
        )
    end

end

I want that X-SMTPAPI header globally included without modifying every mailer method..

这样做的最佳途径是什么?

感谢!

乍得

最佳回答

这令人感到羞耻,因为你不使用有新的<条码>的铁路3号。 邮递:Base.default 您可使用的方法,以适用Edit:我没有通知你,标题中是铁路3。 在该案中,在座标/申请中添加这一点。 rb:

config.action_mailer.default "X-SMTPAPI" =>  {"category": "Test Category"} 

关于铁路2.x,你提出两种选择;使用一种假象,例如,以界定一种先验风格的传导器,把头盔或mon-path Actionmailer带上台,使其做你想要做的事情。 我很害怕,也不是特别棘手的解决办法。

这里的是一个很好的例子,表明有人想做同样的事情,以及你如何做key,但用地址而不是头盔。

问题回答
ActionMailer::Base.default "X-SMTPAPI" =>  {"category": "Test Category"} 

http://www.strong>NOT。

config.action_mailer.default "X-SMTPAPI" =>  {"category": "Test Category"}  # DOES NOT WORK

你们可以界定一个超级等级,界定这一方法,简单地确定负责人:

class MailBase < ActionMailer::Base
  def test_email
    # sendgrid headers go here
  end
end

之后,您的班子继承了这一类:

class MailSub < MailBase
  def test_email
    # email stuff goes here
    super
  end
 end

www.un.org/Depts/DGACM/index_french.htm 此处使用的方法将称为“<代码>测试——电子邮箱:方法”,从而增加电网头。





相关问题
rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

SSL slowness in EC2

We ve deployed our rails app to EC2. In our setup, we have two proxies on small instances behind round-robin DNS. These run nginx load balancers for a dynamically growing and shrinking farm of web ...

Auth-code with A-Za-z0-9 to use in an URL parameter

As part of a web application I need an auth-code to pass as a URL parameter. I am currently using (in Rails) : Digest::SHA1.hexdigest((object_id + rand(255)).to_s) Which provides long strings like : ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

activerecord has_many :through find with one sql call

I have a these 3 models: class User < ActiveRecord::Base has_many :permissions, :dependent => :destroy has_many :roles, :through => :permissions end class Permission < ActiveRecord::...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...

热门标签