Please sign in to comment.
Deprecate `*_path` methods in mailers
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 `*_url` methods instead. Currently if a developer uses a `*_path` helper, their tests and `mail_view` will not catch the mistake. The only way to see the error is by sending emails in production. Preventing sending out emails with non-working path's is the desired end goal of this PR. Currently path helpers are mixed-in to controllers (the ActionMailer::Base acts as a controller). All `*_url` and `*_path` helpers are made available through the same module. This PR separates this behavior into two modules so we can extend the `*_path` methods to add a Deprecation to them. Once deprecated we can use this same area to raise a NoMethodError and add an informative message directing the developer to use `*_url` instead. The module with warnings is only mixed in when a controller returns false from the newly added `supports_relative_path?`. Paired @sgrif & @schneems
- Loading branch information...
Showing with 183 additions and 57 deletions.
- +6 −0 actionmailer/CHANGELOG.md
- +5 −0 actionmailer/lib/action_mailer/base.rb
- +1 −1 actionmailer/lib/action_mailer/railtie.rb
- +8 −0 actionpack/lib/abstract_controller/base.rb
- +3 −3 actionpack/lib/abstract_controller/railties/routes_helpers.rb
- +72 −48 actionpack/lib/action_dispatch/routing/route_set.rb
- +14 −0 actionpack/test/routing/helper_test.rb
- +3 −2 actionview/lib/action_view/rendering.rb
- +16 −0 guides/source/action_mailer_basics.md
- +1 −1 railties/lib/rails/engine.rb
- +2 −2 railties/test/application/initializers/frameworks_test.rb
- +52 −0 railties/test/application/mailer_previews_test.rb