Docs around helpers in mailers is very unclear

This doc isn’t very helpful: Action Mailer Basics — Ruby on Rails Guides

Getting Started with Rails — Ruby on Rails Guides mention the word “helper” a few times but never defines what a helper is or how you should work with one.

If you google rails mail view helpers (I wanted to use a method that’s defined in a view helper in a mailer view) there’s a lot of answers that don’t seem to work very well.

I eventually stumbled on Deletes the private method add_template_helper · rails/rails@cb3b37b · GitHub which breaks the top answer here, and based on that figured out that you should use helpers ModuleName, which is not a pattern I’d seen before.

I am happy to write docs but would love confirmation that I’m doing it right.

1 Like

Actually, I ended up on this pattern:


Which isn’t a fun time. The include calls are needed to use code from helpers in mailer (.rb) code, the helper calls are needed to use code from helpers in views (.haml).

I think we have to include because in config/application.rb we do config.action_controller.include_all_helpers = false. It’s all super unclear and I’m kinda just guessing until the tests pass.

1 Like