Skip to content

Explicitly load ApplicationHelper in ApplicationController#19

Open
tfe wants to merge 2 commits intoharrison-broadbent:mainfrom
tfe:main
Open

Explicitly load ApplicationHelper in ApplicationController#19
tfe wants to merge 2 commits intoharrison-broadbent:mainfrom
tfe:main

Conversation

@tfe
Copy link

@tfe tfe commented Jul 1, 2025

This should fix #18. I noticed that the main controller was not inheriting from ApplicationController, so I also changed that. Let me know if that shouldn't be the case, and I can move the helper call to the other controller.

tfe added 2 commits June 30, 2025 22:48
This seems like possibly an oversight... if ApplicationController exists it seems like other controllers in the engine should inherit from it.
As described here: harrison-broadbent#18

When the Rails app loading this engine is configured with `include_all_helpers = false` (docs here: https://guides.rubyonrails.org/configuring.html#configuring-action-controller), it causes better_mailer_previews's helpers to be inaccessible in its controller/views.

To fix this, explicitly load the helper in our ApplicationController instead implicitly relying on Rails's default behavior of including all helpers everywhere.
@harrison-broadbent
Copy link
Owner

@tfe thank you for opening that issue (#18) and then drafting this PR!

I'm happy in principal with these changes (and it was 100% a mistake not to be inheriting from ApplicationController btw, so thanks for finding that). Give me a few days to find time to test this out, but I should be find to merge this with no further changes needed 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Helper methods (e.g. preview_text_for_url) can't be found when Rails app is configured with include_all_helpers = false

2 participants