-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Evaluate mailer from address at runtime
We're reading the value from the database, but the `ApplicationMailer.default` method is evaluated when the application is started. So if we don't use a Proc, we'll need to restart the server every time we change the value in the database, or else the old value will still be used. Using a Proc makes sure the mailer from address is evaluated at runtime, so emails are sent using the from address currently defined in the database. The same situation took place using the devise mailer. Now we don't need to check for the settings table being present because the Proc in the devise initializer won't be evaluated before the settings table is created and populated.
- Loading branch information
Showing
4 changed files
with
20 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
class ApplicationMailer < ActionMailer::Base | ||
helper :settings | ||
helper :application | ||
default from: "#{Setting["mailer_from_name"]} <#{Setting["mailer_from_address"]}>" | ||
default from: Proc.new { "#{Setting["mailer_from_name"]} <#{Setting["mailer_from_address"]}>" } | ||
layout "mailer" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters