Class: Jets::MailersController
- Inherits:
-
Controller::Base
- Object
- Lambda::Functions
- Controller::Base
- Jets::MailersController
- Defined in:
- lib/jets/internal/app/controllers/jets/mailers_controller.rb
Overview
:nodoc:
Constant Summary
Constants included from Router::Helpers::CoreHelper
Router::Helpers::CoreHelper::CONTROLLER_DELEGATES
Instance Attribute Summary
Attributes inherited from Controller::Base
Attributes inherited from Lambda::Functions
Instance Method Summary collapse
-
#index ⇒ Object
TODO: content_security_policy content_security_policy(false).
- #preview ⇒ Object
Methods inherited from Controller::Base
#action_name, #controller_name, #controller_paths, #dispatch!, #event_log, helper_method, #initialize, internal, #json_dump, #log_finish, #log_start, process, #process!
Methods included from Controller::Rendering
#actual_host, #add_stage_name, #adjust_content_type!, #default_layout, #ensure_render, #managed_options, #normalize_options, #render, #url_for
Methods included from Controller::Redirection
#ensure_protocol, #redirect_back, #redirect_to
Methods included from Controller::Params
#body_params, #filtered_parameters, #params, #path_params, #query_params, #request_params, #unescape_recursively
Methods included from Router::Helpers::NamedRoutesHelper
Methods included from Router::Helpers::CoreHelper
Methods included from Controller::ForgeryProtection
Methods included from Controller::Cookies
Methods inherited from Lambda::Functions
inherited, #initialize, output_keys, subclasses
Methods included from Lambda::Dsl
Constructor Details
This class inherits a constructor from Jets::Controller::Base
Instance Method Details
#index ⇒ Object
TODO: content_security_policy content_security_policy(false)
15 16 17 18 |
# File 'lib/jets/internal/app/controllers/jets/mailers_controller.rb', line 15 def index @previews = ActionMailer::Preview.all @page_title = "Mailer Previews" end |
#preview ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/jets/internal/app/controllers/jets/mailers_controller.rb', line 20 def preview if params[:path] == @preview.preview_name @page_title = "Mailer Previews for #{@preview.preview_name}" render :mailer else @email_action = File.basename(params[:path]) if @preview.email_exists?(@email_action) @email = @preview.call(@email_action, params) if params[:part] part_type = Mime::Type.lookup(params[:part]) if part = find_part(part_type) response.headers["Content-Type"] = params[:part] render plain: part.respond_to?(:decoded) ? part.decoded : part else raise AbstractController::ActionNotFound, "Email part '#{part_type}' not found in #{@preview.name}##{@email_action}" end else @part = find_preferred_part(Mime[:html], Mime[:text]) render :email, layout: false, formats: %w[html] end else raise AbstractController::ActionNotFound, "Email '#{@email_action}' not found in #{@preview.name}" end end end |