Email preview in production in rails 4

瀏覽次數:133 次
跳到第一則未讀訊息

Hristo Peev

未讀,
2014年12月11日 上午11:17:292014/12/11
收件者:rubyonra...@googlegroups.com

Hello,

I am using rails 4.1.1 and ActionMailer::Preview. In development environment everything is working excellent.

But in production environment the preview routes are not accessible. I store the previews in test/mailers/previews/
Is is possible to enable them for production?

Thanks!

jbar

未讀,
2015年1月7日 下午4:54:512015/1/7
收件者:rubyonra...@googlegroups.com
Did you ever find a solution? I'm looking to do the same thing.

Hristo Peev

未讀,
2015年1月8日 凌晨3:13:572015/1/8
收件者:rubyonra...@googlegroups.com
Hi, 

I have a clue, but I haven't tested it yet.

Try to add the routes in your routes.rb file manually.

If you have a chance to test this, please, write a line about the results.

Thanks!

Harshvardhan Parihar

未讀,
2015年2月18日 上午11:27:112015/2/18
收件者:rubyonra...@googlegroups.com
Did u get the solution for this issue.

Hristo Peev

未讀,
2015年2月19日 凌晨12:58:242015/2/19
收件者:rubyonra...@googlegroups.com
Hi, 

I have a clue, but I haven't tested it yet.

Try to add the routes in your routes.rb file manually.

If you have a chance to test this, please, write a line about the results.

Thanks!

Mike

未讀,
2015年3月8日 清晨7:36:432015/3/8
收件者:rubyonra...@googlegroups.com
You should not really do this as the whole point of the production environment is to be live and sending mails

The content should not be different to your test or development environment so I am not sure what issue you think you are having

However if you want to do this, then I would suggest something like the mailcatcher gem and temporarily reset your production SMTP settings to use that, however as I said above there should be no need to do this assuming you have tested your app previously

Obviously if you reset your SMTP settings to use mailcatcher then no one will receive any live email from your app

Michael Johnston

未讀,
2016年9月8日 下午5:37:222016/9/8
收件者:Ruby on Rails: Talk
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.


##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

Michael Johnston

未讀,
2016年9月8日 下午5:37:222016/9/8
收件者:Ruby on Rails: Talk


On Sunday, March 8, 2015 at 4:36:43 AM UTC-7, Mike wrote:
You should not really do this as the whole point of the production environment is to be live and sending mails


It's been a year so perhaps your imagination or experience has expanded, but in case not how about this perfectly legitimate use case: the client who contracted the development of the app would like to be able to view the various mails that the app sends.
回覆所有人
回覆作者
轉寄
0 則新訊息