Search code examples
ruby-on-railsruby-on-rails-3.2rubygemsmonkeypatching

Add method to a gem's helpers


I am using a gem which adds a number of View helpers under the following module hierarchy:

module Ransack
  module Helpers
    module FormHelpers
      def search_form_for
      end
    end
  end
end

ActionController::Base.helper Ransack::Helpers::FormHelper

I want to add my own helper method into the same module hierarchy, and make it available to all views. How do I do this?


Solution

  • What's the point of altering the gem with additional methods? If it's a view helper, simply create an appropriate file in the app/helpers directory of your app and add your custom helper there.

    The custom helper will be available to all views.