Skip to content

page_entries_info conflict between Kaminari and Will_paginate #254

Closed
kwent opened this Issue Jul 25, 2012 · 3 comments

4 participants

@kwent
kwent commented Jul 25, 2012

Hello,

I noticed two page_entries_info methods

First in will_paginate and another one in Kaminari in lib/kaminari/helpers/action_view_extension.rb

def page_entries_info(collection, options = {})
      entry_name = options[:entry_name] || (collection.empty? ? 'entry' : collection.first.class.name.underscore.sub('_', ' '))

      entry_name = if collection.empty?
        'entry'
      elsif options[:entry_name]
        options[:entry_name]
      else
        if collection.respond_to? :model # DataMapper
          collection.model.model_name.human.downcase
        else # AR
          collection.model_name.human.downcase
        end
      end
      entry_name = entry_name.pluralize unless collection.total_count == 1

      if collection.total_pages < 2
        t('helpers.page_entries_info.one_page.display_entries', :entry_name => entry_name, :count => collection.total_count)
      else
        first = collection.offset_value + 1
        last = collection.last_page? ? collection.total_count : collection.offset_value + collection.limit_value
        t('helpers.page_entries_info.more_pages.display_entries', :entry_name => entry_name, :first => first, :last => last, :total => collection.total_count)
      end.html_safe
    end

My problem is that Kaminari Method not work well with (:to option is not correct), so i would use WillPaginate function.

I tried to specify in my view that i want WillPaginate page_entries_info function without success with

WillPaginate::ActionView.page_entries_info @posts

Only solution for the moment is to delete Kaminary page_entries_info and so my view select WillPaginate page_entries_info and everything works well.

Could you help me to fix this issue without modify Kaminary source code ?

Regards,

@PrototypeAlex

You aren't alone on this one, I've just stumbled into the same problem when I upgraded kaminari to 0.14.1.

@shime
shime commented Oct 3, 2012

Hey guys! Why are you using two different gems for pagination? How is :to option incorrect in Kaminari?

@mislav
Owner
mislav commented Jan 10, 2013

Dup of #181

@mislav mislav closed this Jan 10, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.