Skip to content

allow mail rendering at delay time #672

Open
wants to merge 1 commit into from

3 participants

@hqm42
hqm42 commented Jun 19, 2014

The current solution to delayed mail delivery renders the mail template at delivery time:

Notifier.delay.signup(@user)

This can lead to problems, if your data that is accessed by the mail template changed between delay time and delivery time.

When you try to explicitly delay delivery forcing rendering you will get an error:

Notifier.signup(@user).delay.deliver
# Use MyMailer.delay.mailer_action(args) to delay sending of emails.

The new approach will serialize the mail message at delay time using Mail::Message.encoded and deserialize using the constructor:

Notifier.signup(@user).delay.deliver
# works like expected (render message -> delay -> execute job -> deliver)

The old approach:

Notifier.delay.signup(@user)
# still works (delay -> execute job -> render message -> deliver)
@hqm42 hqm42 allow mail rendering at delay time
The current solution to delayed mail delivery renders the mail template at delivery time:
    Notifier.delay.signup(@user)

When you try to explicitly delay delivery you will get an error:
    Notifier.signup(@user).delay.deliver
    > Use MyMailer.delay.mailer_action(args) to delay sending of emails.

The new approach will serialize the mail message at delay time using Mail::Message.encoded and deserialize using the constructor:
    Notifier.signup(@user).delay.deliver
4f7ee8f
@wgc-as
wgc-as commented Dec 8, 2014

+1 When will this be merged in?

@albus522
Collective Idea member
albus522 commented Apr 2, 2015

My primary concern with this is that it seriously increases the risk of a silent serialization errors due to exceeding the handler size. We get a lot of confusion when databases like Mysql simply truncate the data and move one. Unfortunately I can't find the conversation about why this is a difficult problem, but the short version is that text fields are reported as unlimited length but they aren't actually unlimited.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.