How to add a Helper to a Rails app Using a Plugin

After the question popped up on irc:


[01:21pm|jcm> about plugins: how can I include helpers in a plugin ?

I decided to investigate. Turns out it’s very simple, as demonstrated by TopFunky:


ActionView::Base.send :include, CssGraphsHelper

Just replace CssGraphsHelper with the name of your helper module, and now just make it in lib:


module CssGraphsHelper
  ...
  ...
  ...
end

Now, you have all the methods you defined available to you. Congratulations!



Comments are closed