Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Deprecate `*_path` methods in mailers #15840
Email does not support relative links since there is no implicit host. Therefore all links inside of emails must be fully qualified URLs. All path helpers are now deprecated. When removed, the error will give early indication to developers to use
Currently if a developer uses a
Currently path helpers are mixed-in to controllers (the ActionMailer::Base acts as a controller). All
The module with warnings is only mixed in when a controller returns false from the newly added
I think deprecating the behaviour would cause some pain. I had mentioned people reuse views in emails.
Example: In one of my projects I used https://github.com/pokonski/public_activity, and render/reuse the same views from web/ update emails.
The problem is, developer is forced to either use multiple views in this case, add a hack, or start using
Any way to overcome this?
@sgrif not sure about the best place. I added one here: https://github.com/rails/rails/pull/15840/files#diff-6cd2f2bc2d75ddac6c0d1e85983e983dR406 in mailer_previews_test
@vipulnsward are you on the rails-contributors mailing list? We've talked about this behavior a bit. Sharing views between emails and mailers should be fine, though right now if they're using
I had a look at the patch. Looks good to me, I like the overall idea of separating URL and path modules.
Regarding the implementation I only have some minor remarks:
Let's iterate a little bit and done!
Moving this logic to the railtie is the only component i'm having problems with. The behavior is deeply nested inside of action view. We need to get this state information to https://github.com/rails/rails/blob/master/actionview/lib/action_view/rendering.rb#L43-L44 somehow. This is included in ActionMailer directly through ActionView::Layouts https://github.com/rails/rails/blob/master/actionmailer/lib/action_mailer/base.rb#L416
This seems like a likely place to add logic, but this doesn't affect path helpers in the view (not actually sure what it is doing): https://github.com/rails/rails/blob/master/actionmailer/lib/action_mailer/railtie.rb#L33
Do you have any ideas or thoughts on how to move this logic to the railtie? cc @sgrif
Updated to proper naming
I'm fine with this, changed to a boolean
Updated to use this technique instead of module injection.
Updated to mention this behavior
For the archives, we've discussed by email adding the same behavior to mailer instances (in addition to their templates).
@schneems I believe we are close. Would you mind doing a couple of last small edits?
Could do that myself after pushing, but if you didn't mind the commit would be more round.
There were a ton of merge conflicts introduced in the last 24 hours (https://github.com/rails/rails/commits/master/actionpack/lib/action_dispatch/routing/route_set.rb). I fixed those. Removed double "instead". Wrote a different last paragraph for the guide. Also had to modify a test that was asserting *_url methods cannot be used directly in mailers. Test introduced 4 years ago, I don't believe the behavior it was asserting was valid.
Looks like build is now green.