Created
April 8, 2017 04:18
-
-
Save kieraneglin/ffbb315b4e990db04dd2ebd7a3dd2fa7 to your computer and use it in GitHub Desktop.
[Include all Rails helpers] If you need access to helpers, even private ones (for a decorator, say), try this. #tags: ruby, rails, helpers, decorators, liquid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module HelperProxy | |
HELPER_DIRECTORY = Dir[Rails.root.join('app', 'helpers', '**', '*.rb')] | |
HELPER_DIRECTORY.each do |file| | |
include file.split(/\/helpers\/(.*?)\.rb/)[1].classify.safe_constantize | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment