Skip to content

Instantly share code, notes, and snippets.

@kieraneglin
Created April 8, 2017 04:18
Show Gist options
  • Save kieraneglin/ffbb315b4e990db04dd2ebd7a3dd2fa7 to your computer and use it in GitHub Desktop.
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
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