Where do I put helper methods for ActionMailer views?

前端 未结 6 1269
无人共我
无人共我 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:02

    In my case, for Rails 5.1, I had to use both include and helper methods, like this:

    include ApplicationHelper
    helper :application
    

    And then just proceed to use the method normally.

    class MyMailer < ActionMailer::Base
      include ApplicationHelper
      helper :application
    
      def my_mailer_method
        my_helper_method_declared_in_application_helper
        ..
      end
    end
    

提交回复
热议问题