diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2017-04-26 20:15:30 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-26 20:15:30 -0700 |
commit | f680664d4e2f81216ee73c047b836d49a796234c (patch) | |
tree | 985f28bfde95728cc010bbe553270ccfb8973c47 /railties/lib/rails | |
parent | 971ceeb844b70a510d2e52c34108894248522797 (diff) | |
parent | 8e6c6d854cdedad4bc082cf45a01d411ea26fb68 (diff) | |
download | rails-f680664d4e2f81216ee73c047b836d49a796234c.tar.gz rails-f680664d4e2f81216ee73c047b836d49a796234c.tar.bz2 rails-f680664d4e2f81216ee73c047b836d49a796234c.zip |
Merge pull request #28244 from ixti/improve/action-mailer-preview-params
Pass request params to ActionMailer::Preview
Diffstat (limited to 'railties/lib/rails')
-rw-r--r-- | railties/lib/rails/mailers_controller.rb | 8 | ||||
-rw-r--r-- | railties/lib/rails/templates/rails/mailers/email.html.erb | 6 |
2 files changed, 10 insertions, 4 deletions
diff --git a/railties/lib/rails/mailers_controller.rb b/railties/lib/rails/mailers_controller.rb index 000ce40fbc..7ff55ef5bf 100644 --- a/railties/lib/rails/mailers_controller.rb +++ b/railties/lib/rails/mailers_controller.rb @@ -6,6 +6,8 @@ class Rails::MailersController < Rails::ApplicationController # :nodoc: before_action :require_local!, unless: :show_previews? before_action :find_preview, only: :preview + helper_method :part_query + def index @previews = ActionMailer::Preview.all @page_title = "Mailer Previews" @@ -19,7 +21,7 @@ class Rails::MailersController < Rails::ApplicationController # :nodoc: @email_action = File.basename(params[:path]) if @preview.email_exists?(@email_action) - @email = @preview.call(@email_action) + @email = @preview.call(@email_action, params) if params[:part] part_type = Mime::Type.lookup(params[:part]) @@ -76,4 +78,8 @@ class Rails::MailersController < Rails::ApplicationController # :nodoc: @email end end + + def part_query(mime_type) + request.query_parameters.merge(part: mime_type).to_query + end end diff --git a/railties/lib/rails/templates/rails/mailers/email.html.erb b/railties/lib/rails/templates/rails/mailers/email.html.erb index c63781ed0c..89c1129f90 100644 --- a/railties/lib/rails/templates/rails/mailers/email.html.erb +++ b/railties/lib/rails/templates/rails/mailers/email.html.erb @@ -98,8 +98,8 @@ <% if @email.multipart? %> <dd> <select onchange="formatChanged(this);"> - <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> + <option <%= request.format == Mime[:html] ? 'selected' : '' %> value="?<%= part_query('text/html') %>">View as HTML email</option> + <option <%= request.format == Mime[:text] ? 'selected' : '' %> value="?<%= part_query('text/plain') %>">View as plain-text email</option> </select> </dd> <% end %> @@ -107,7 +107,7 @@ </header> <% if @part && @part.mime_type %> - <iframe seamless name="messageBody" src="?part=<%= Rack::Utils.escape(@part.mime_type) %>"></iframe> + <iframe seamless name="messageBody" src="?<%= part_query(@part.mime_type) %>"></iframe> <% else %> <p> You are trying to preview an email that does not have any content. |