diff options
author | @schneems and @sgrif <sean@thoughtbot.com> | 2014-06-19 17:26:29 -0500 |
---|---|---|
committer | schneems <richard.schneeman@gmail.com> | 2014-07-30 12:01:45 -0500 |
commit | 2bbcca004cc232cef868cd0e301f274ce5638df0 (patch) | |
tree | c0b460531e5460ab32fe9fb354f52c697405c648 /actionpack/lib/abstract_controller/railties | |
parent | 4efb36e7b44ae3facb948aa3c5f2790a3fd3b61a (diff) | |
download | rails-2bbcca004cc232cef868cd0e301f274ce5638df0.tar.gz rails-2bbcca004cc232cef868cd0e301f274ce5638df0.tar.bz2 rails-2bbcca004cc232cef868cd0e301f274ce5638df0.zip |
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
Diffstat (limited to 'actionpack/lib/abstract_controller/railties')
-rw-r--r-- | actionpack/lib/abstract_controller/railties/routes_helpers.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/actionpack/lib/abstract_controller/railties/routes_helpers.rb b/actionpack/lib/abstract_controller/railties/routes_helpers.rb index 6684f46f64..568c47e43a 100644 --- a/actionpack/lib/abstract_controller/railties/routes_helpers.rb +++ b/actionpack/lib/abstract_controller/railties/routes_helpers.rb @@ -1,14 +1,14 @@ module AbstractController module Railties module RoutesHelpers - def self.with(routes) + def self.with(routes, include_path_helpers = true) Module.new do define_method(:inherited) do |klass| super(klass) if namespace = klass.parents.detect { |m| m.respond_to?(:railtie_routes_url_helpers) } - klass.send(:include, namespace.railtie_routes_url_helpers) + klass.send(:include, namespace.railtie_routes_url_helpers(include_path_helpers)) else - klass.send(:include, routes.url_helpers) + klass.send(:include, routes.url_helpers(include_path_helpers)) end end end |