Question

I'm trying to monkey patch a gem's view helper method without success. It's being ignored and the original gem code runs. Where should I put the file to have it run?

I created the file lib/kaminari.rb containing (lib/ is in load path):

module Kaminari
  module Helpers

    class Tag

      def page_url_for(page)
        if @params[:controller] =~ /fc_rseries/
          My::Engine.routes.url_helpers.url_for @params.merge(@param_name => (page <= 1 ? nil : page), :only_path=>true).symbolize_keys
        else
          @template.url_for @params.merge(@param_name => (page <= 1 ? nil : page))
        end
      end

    end

  end
end
Was it helpful?

Solution

I added the file in app/helpers

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top