سؤال

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
هل كانت مفيدة؟

المحلول

I added the file in app/helpers

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top