Ruby on Rails Thursday, September 8, 2016

This is how I did it. For those having trouble imagining the use case, it was so the client who pays for the app could easily review the many mails the app sends.

http://stackoverflow.com/questions/27453578/rails-4-email-preview-in-production/39399116#39399116

##production.rb

    MyApp::Application.configure do
      config.action_mailer.preview_path ||= defined?(Rails.root) ? "#{Rails.root}/spec/mailer_previews" : nil
      config.autoload_paths += [config.action_mailer.preview_path]

      routes.append do
        get '/rails/mailers'         => "rails/mailers#index"
        get '/rails/mailers/*path'   => "rails/mailers#preview"
      end
    end

    class ::Rails::MailersController
      before_filter :authenticate_admin!
      def local_request?
        true
      end
      private
      def authenticate_admin!
        ...
      end
    end

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/4b5ea4e3-e1e9-41da-9094-3421387bdbc3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment