weppos / actionmailer_with_request

A simple plugin to make the Rails request context available for generating URLs in ActionMailer.
MIT License
54 stars 8 forks source link

Modernize overrides. #11

Closed eric1234 closed 7 years ago

eric1234 commented 8 years ago

Using more recent versions of Ruby means we can:

In addition I:

The primary reason for this commit was to replace the alias_method_chain with prepend. I'm want the request info to be used in Mandrill templated e-mails as well. I'm using mandrill_mailer gem which has a ActionMailer-like API. The default url options override that this gem provides couldn't be applied there because default_url_options is not a real method in mandrill_mailer so alias_method_chain doesn't work. The more modern prepend does work. This commit allows me to get use it for my purposes as well as modernize this gem a bit.

For those wanting to also use it for the mandrill_mailer gem you just need to add the following to your initializer if using this commit:

Rails.application.config.mandrill_mailer.default_url_options = { host: 'yourdomain.com' }
MandrillMailer.config.singleton_class.prepend ActionMailerWithRequest::DefaultUrlOptionsOverride
weppos commented 7 years ago

Using more recent versions of Ruby means we can:

This PR relies on this assumption, but there is nothing preventing to use an older version of Ruby with this gem. In fact, this gem is supposed to be compatible with Rails 3 (and Ruby 1.9).

I will go ahead and merge, but I also have to plan upgrading the requirements.

weppos commented 7 years ago

@eric1234 can you try master and let me know if it works?

eric1234 commented 7 years ago

Yes my assumption is that people on older versions of Ruby can continue to use older versions of this gem. I should have some time tomorrow to try the merged version of this on an app (I was previously using my branch with success).