From edaa2c48179681efd96d0cad4b5dea696a2a31fb Mon Sep 17 00:00:00 2001 From: Robert Pankowecki Date: Fri, 15 Jun 2012 17:20:47 +0000 Subject: Introduce config.action_mailer.default_from= Allows to easily set :from, :replay_to, etc. options in config/application.rb using simple syntax: config.action_mailer.default_options = {from:"no-replay@example.org"} This was not possible using #default method because config.action_mailer.default(from: "no-replay@example.org") is interpreated as reader method and just returns nil. It would not call ActionMailer::Base.default method. The only way of calling this method from config/application.rb was to use the direct syntax which looks ugly in my opinion: config.assets.enabled = false config.assets.version = '1.0' config.encoding = "utf-8" config.action_mailer.default_url_options= { host:"example.org", protocol:"https" } ActionMailer::Base.default(from: "no-replay@example.org") --- actionmailer/lib/action_mailer/base.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'actionmailer/lib') diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index f31e1e007b..ea9a08102f 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -421,6 +421,9 @@ module ActionMailer #:nodoc: self.default_params = default_params.merge(value).freeze if value default_params end + #Alias so that we can use it in config/application.rb which requires setters + #: config.action_mailer.default_options = {from: "no-replay@example.org"} + alias :default_options= :default # Receives a raw email, parses it into an email object, decodes it, # instantiates a new mailer, and passes the email object to the mailer @@ -786,4 +789,4 @@ module ActionMailer #:nodoc: ActiveSupport.run_load_hooks(:action_mailer, self) end -end \ No newline at end of file +end -- cgit v1.2.3