Where do I put helper methods for ActionMailer views?

前端 未结 6 1258
无人共我
无人共我 2020-12-09 16:41

I have a method that takes an array of strings and joins them so they do something like this:

>> my_arr
=> [\"A\", \"B\", \"C\"]
>> and_join(m         


        
6条回答
  •  北海茫月
    2020-12-09 17:07

    If you have some one off methods you want to use in the view, you can use helper_method directly in your mailer.

    class MyMailer < ApplicationMailer
      def mailer
        mail to: '', subject: ''
      end
    
      private
    
      helper_method def something_to_use_in_the_view
      end
    end
    

    something_to_use_in_the_view will be available in your view.

提交回复
热议问题