diff options
author | Jeremy Daer <jeremydaer@gmail.com> | 2015-10-04 22:14:04 -0700 |
---|---|---|
committer | Jeremy Daer <jeremydaer@gmail.com> | 2015-10-06 11:29:30 -0700 |
commit | 565094a8b5cdfa158fef6ae75252fd98a4ba8fe4 (patch) | |
tree | 78cc5fc25b114c26e14d855370e16139dbd4b679 /railties/lib | |
parent | 5b69e30622de27e8010fd8cb32a97b5f0fe194e2 (diff) | |
download | rails-565094a8b5cdfa158fef6ae75252fd98a4ba8fe4.tar.gz rails-565094a8b5cdfa158fef6ae75252fd98a4ba8fe4.tar.bz2 rails-565094a8b5cdfa158fef6ae75252fd98a4ba8fe4.zip |
Use `Mime[:foo]` instead of `Mime::Type[:FOO]` for back compat
Rails 4.x and earlier didn't support `Mime::Type[:FOO]`, so libraries
that support multiple Rails versions would've had to feature-detect
whether to use `Mime::Type[:FOO]` or `Mime::FOO`.
`Mime[:foo]` has been around for ages to look up registered MIME types
by symbol / extension, though, so libraries and plugins can safely
switch to that without breaking backward- or forward-compatibility.
Note: `Mime::ALL` isn't a real MIME type and isn't registered for lookup
by type or extension, so it's not available as `Mime[:all]`. We use it
internally as a wildcard for `respond_to` negotiation. If you use this
internal constant, continue to reference it with `Mime::ALL`.
Ref. efc6dd550ee49e7e443f9d72785caa0f240def53
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/rails/mailers_controller.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/templates/rails/mailers/email.html.erb | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/railties/lib/rails/mailers_controller.rb b/railties/lib/rails/mailers_controller.rb index 38004fe99a..6143cf2dd9 100644 --- a/railties/lib/rails/mailers_controller.rb +++ b/railties/lib/rails/mailers_controller.rb @@ -31,7 +31,7 @@ class Rails::MailersController < Rails::ApplicationController # :nodoc: raise AbstractController::ActionNotFound, "Email part '#{part_type}' not found in #{@preview.name}##{@email_action}" end else - @part = find_preferred_part(request.format, Mime::Type[:HTML], Mime::Type[:TEXT]) + @part = find_preferred_part(request.format, Mime[:html], Mime[:text]) render action: 'email', layout: false, formats: %w[html] end else diff --git a/railties/lib/rails/templates/rails/mailers/email.html.erb b/railties/lib/rails/templates/rails/mailers/email.html.erb index cf95cd8ad0..3adc51b568 100644 --- a/railties/lib/rails/templates/rails/mailers/email.html.erb +++ b/railties/lib/rails/templates/rails/mailers/email.html.erb @@ -95,8 +95,8 @@ <% if @email.multipart? %> <dd> <select onchange="document.getElementsByName('messageBody')[0].src=this.options[this.selectedIndex].value;"> - <option <%= request.format == Mime::Type[:HTML] ? 'selected' : '' %> value="?part=text%2Fhtml">View as HTML email</option> - <option <%= request.format == Mime::Type[:TEXT] ? 'selected' : '' %> value="?part=text%2Fplain">View as plain-text email</option> + <option <%= request.format == Mime[:html] ? 'selected' : '' %> value="?part=text%2Fhtml">View as HTML email</option> + <option <%= request.format == Mime[:text] ? 'selected' : '' %> value="?part=text%2Fplain">View as plain-text email</option> </select> </dd> <% end %> |