kaminari 0.13.0 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of kaminari might be problematic. Click here for more details.

Files changed (87) hide show
  1. data/.gitignore +2 -0
  2. data/.travis.yml +8 -1
  3. data/CHANGELOG +46 -10
  4. data/README.rdoc +14 -3
  5. data/Rakefile +22 -2
  6. data/app/views/kaminari/_first_page.html.erb +1 -1
  7. data/app/views/kaminari/_first_page.html.haml +1 -1
  8. data/app/views/kaminari/_first_page.html.slim +1 -1
  9. data/app/views/kaminari/_gap.html.erb +1 -1
  10. data/app/views/kaminari/_gap.html.haml +1 -1
  11. data/app/views/kaminari/_gap.html.slim +1 -1
  12. data/app/views/kaminari/_last_page.html.erb +1 -1
  13. data/app/views/kaminari/_last_page.html.haml +1 -1
  14. data/app/views/kaminari/_last_page.html.slim +1 -1
  15. data/app/views/kaminari/_next_page.html.erb +1 -1
  16. data/app/views/kaminari/_next_page.html.haml +1 -1
  17. data/app/views/kaminari/_next_page.html.slim +1 -1
  18. data/app/views/kaminari/_page.html.erb +2 -2
  19. data/app/views/kaminari/_page.html.haml +1 -1
  20. data/app/views/kaminari/_page.html.slim +1 -1
  21. data/app/views/kaminari/_paginator.html.erb +1 -1
  22. data/app/views/kaminari/_paginator.html.haml +1 -1
  23. data/app/views/kaminari/_paginator.html.slim +1 -1
  24. data/app/views/kaminari/_prev_page.html.erb +1 -1
  25. data/app/views/kaminari/_prev_page.html.haml +1 -1
  26. data/app/views/kaminari/_prev_page.html.slim +1 -1
  27. data/config/locales/kaminari.yml +9 -0
  28. data/gemfiles/active_record_30.gemfile +7 -0
  29. data/gemfiles/active_record_31.gemfile +7 -0
  30. data/gemfiles/active_record_32.gemfile +7 -0
  31. data/gemfiles/data_mapper_12.gemfile +12 -0
  32. data/gemfiles/mongo_mapper.gemfile +7 -0
  33. data/gemfiles/mongoid_24.gemfile +7 -0
  34. data/gemfiles/mongoid_30.gemfile +7 -0
  35. data/gemfiles/sinatra.gemfile +10 -0
  36. data/kaminari.gemspec +6 -18
  37. data/lib/generators/kaminari/templates/kaminari_config.rb +1 -0
  38. data/lib/kaminari.rb +22 -57
  39. data/lib/kaminari/config.rb +7 -1
  40. data/lib/kaminari/grape.rb +4 -0
  41. data/lib/kaminari/helpers/action_view_extension.rb +84 -13
  42. data/lib/kaminari/helpers/paginator.rb +8 -5
  43. data/lib/kaminari/helpers/sinatra_helpers.rb +25 -6
  44. data/lib/kaminari/helpers/tags.rb +1 -1
  45. data/lib/kaminari/hooks.rb +12 -10
  46. data/lib/kaminari/models/active_record_relation_methods.rb +0 -3
  47. data/lib/kaminari/models/configuration_methods.rb +15 -1
  48. data/lib/kaminari/models/page_scope_methods.rb +6 -2
  49. data/lib/kaminari/models/plucky_criteria_methods.rb +3 -0
  50. data/lib/kaminari/railtie.rb +2 -2
  51. data/lib/kaminari/sinatra.rb +2 -10
  52. data/lib/kaminari/version.rb +1 -1
  53. data/spec/config/config_spec.rb +15 -0
  54. data/spec/fake_app/active_record/config.rb +3 -0
  55. data/spec/{fake_app.rb → fake_app/active_record/models.rb} +7 -34
  56. data/spec/fake_app/data_mapper/config.rb +1 -0
  57. data/spec/fake_app/data_mapper/models.rb +27 -0
  58. data/spec/fake_app/mongo_mapper/config.rb +2 -0
  59. data/spec/fake_app/mongo_mapper/models.rb +9 -0
  60. data/spec/fake_app/mongoid/config.rb +16 -0
  61. data/spec/fake_app/mongoid/models.rb +22 -0
  62. data/spec/fake_app/rails_app.rb +55 -0
  63. data/spec/fake_app/sinatra_app.rb +22 -0
  64. data/spec/fake_gem.rb +0 -2
  65. data/spec/helpers/action_view_extension_spec.rb +192 -45
  66. data/spec/helpers/helpers_spec.rb +8 -8
  67. data/spec/helpers/sinatra_helpers_spec.rb +129 -133
  68. data/spec/helpers/tags_spec.rb +8 -8
  69. data/spec/models/active_record/active_record_relation_methods_spec.rb +30 -0
  70. data/spec/models/active_record/default_per_page_spec.rb +32 -0
  71. data/spec/models/active_record/max_per_page_spec.rb +32 -0
  72. data/spec/models/active_record/scopes_spec.rb +166 -0
  73. data/spec/models/array_spec.rb +7 -7
  74. data/spec/models/data_mapper/data_mapper_spec.rb +155 -0
  75. data/spec/models/mongo_mapper/mongo_mapper_spec.rb +72 -0
  76. data/spec/models/mongoid/mongoid_spec.rb +110 -0
  77. data/spec/requests/users_spec.rb +0 -1
  78. data/spec/spec_helper.rb +20 -18
  79. data/spec/spec_helper_for_sinatra.rb +22 -0
  80. data/spec/support/database_cleaner.rb +4 -1
  81. metadata +93 -141
  82. data/spec/models/active_record_relation_methods_spec.rb +0 -28
  83. data/spec/models/data_mapper_spec.rb +0 -181
  84. data/spec/models/default_per_page_spec.rb +0 -29
  85. data/spec/models/mongo_mapper_spec.rb +0 -82
  86. data/spec/models/mongoid_spec.rb +0 -129
  87. data/spec/models/scopes_spec.rb +0 -163
@@ -0,0 +1,12 @@
1
+ source :rubygems
2
+
3
+ gem 'railties', '>= 3.2.3'
4
+ gem 'dm-core', '>= 1.2.0'
5
+ gem 'dm-migrations', '>= 1.2.0'
6
+ gem 'dm-aggregates', '>= 1.2.0'
7
+ gem 'dm-transactions', '>= 1.2.0'
8
+ gem 'dm-active_model', '>= 1.2.0'
9
+ gem 'dm-sqlite-adapter', '>= 1.2.0'
10
+ gem 'rspec-rails', '>= 2.0'
11
+
12
+ gemspec :path => '../'
@@ -0,0 +1,7 @@
1
+ source :rubygems
2
+
3
+ gem 'railties', '>= 3.2.3'
4
+ gem 'mongo_mapper', '>= 0.11.0'
5
+ gem 'rspec-rails', '>= 2.0'
6
+
7
+ gemspec :path => '../'
@@ -0,0 +1,7 @@
1
+ source :rubygems
2
+
3
+ gem 'railties', '>= 3.2.3'
4
+ gem 'mongoid', '~> 2.4.0'
5
+ gem 'rspec-rails', '>= 2.0'
6
+
7
+ gemspec :path => '../'
@@ -0,0 +1,7 @@
1
+ source :rubygems
2
+
3
+ gem 'railties', '>= 3.2.3'
4
+ gem 'mongoid', '>= 3.0'
5
+ gem 'rspec-rails', '>= 2.0'
6
+
7
+ gemspec :path => '../'
@@ -0,0 +1,10 @@
1
+ source :rubygems
2
+
3
+ gem 'activerecord', '>= 3.2.3', :require => 'active_record'
4
+ gem 'sinatra', '>= 1.3'
5
+ gem 'padrino-helpers', '>= 0.10.6.c'
6
+ gem 'rack-test', '>= 0'
7
+ gem 'sinatra-contrib', '>= 1.3'
8
+ gem 'nokogiri', '>= 0'
9
+
10
+ gemspec :path => '../'
@@ -21,28 +21,16 @@ Gem::Specification.new do |s|
21
21
 
22
22
  s.licenses = ['MIT']
23
23
 
24
- %w{ activesupport actionpack railties }.each do |gem|
25
- s.add_dependency gem, ['>= 3.0.0']
26
- end
24
+ s.add_dependency 'activesupport', ['>= 3.0.0']
25
+ s.add_dependency 'actionpack', ['>= 3.0.0']
26
+
27
27
  s.add_development_dependency 'bundler', ['>= 1.0.0']
28
+ s.add_development_dependency 'rake', ['>= 0']
28
29
  s.add_development_dependency 'sqlite3', ['>= 0']
29
- %w{ activerecord activemodel }.each do |gem|
30
- s.add_development_dependency gem, ['>= 3.0.0']
31
- end
32
- s.add_development_dependency 'sinatra', ['>= 1.3']
33
- s.add_development_dependency 'mongoid', ['>= 2']
34
- s.add_development_dependency 'mongo_mapper', ['>= 0.9']
35
- s.add_development_dependency 'dm-core', ['>= 1.1.0']
36
- s.add_development_dependency 'dm-migrations', ['>= 1.1.0']
37
- s.add_development_dependency 'dm-aggregates', ['>= 1.1.0']
38
- s.add_development_dependency 'dm-sqlite-adapter', ['>= 1.1.0']
30
+ s.add_development_dependency 'tzinfo', ['>= 0']
39
31
  s.add_development_dependency 'rspec', ['>= 0']
40
- s.add_development_dependency 'rspec-rails', ['>= 0']
41
32
  s.add_development_dependency 'rr', ['>= 0']
42
33
  s.add_development_dependency 'capybara', ['>= 1.0']
43
34
  s.add_development_dependency 'database_cleaner', ['>= 0']
44
- s.add_development_dependency 'padrino-helpers', ['~> 0.10']
45
- s.add_development_dependency 'rack-test', ['>= 0']
46
- s.add_development_dependency 'sinatra-contrib', ['~> 1.3']
47
- s.add_development_dependency 'nokogiri', ['>= 0']
35
+ s.add_development_dependency 'rdoc', ['>= 0']
48
36
  end
@@ -1,5 +1,6 @@
1
1
  Kaminari.configure do |config|
2
2
  # config.default_per_page = 25
3
+ # config.max_per_page = nil
3
4
  # config.window = 4
4
5
  # config.outer_window = 0
5
6
  # config.left = 0
@@ -1,73 +1,38 @@
1
1
  module Kaminari
2
- def self.frameworks
3
- frameworks = []
4
- case
5
- when rails? then frameworks << 'rails'
6
- when sinatra? then frameworks << 'sinatra/base'
7
- end
8
- frameworks
9
- end
2
+ end
10
3
 
11
- def self.load_framework!
12
- show_warning if frameworks.empty?
13
- frameworks.each do |framework|
14
- begin
15
- require framework
16
- rescue NameError => e
17
- raise "Failed to load framework #{framework.inspect}. Have you added it to Gemfile?"
18
- end
19
- end
20
- end
4
+ # load Rails/Railtie
5
+ begin
6
+ require 'rails'
7
+ rescue LoadError
8
+ #do nothing
9
+ end
21
10
 
22
- def self.show_warning
23
- $stderr.puts <<-EOC
11
+ $stderr.puts <<-EOC if !defined?(Rails) && !defined?(Sinatra) && !defined?(Grape)
24
12
  warning: no framework detected.
25
13
  would you check out if your Gemfile appropriately configured?
26
14
  ---- e.g. ----
27
15
  when Rails:
28
- gem 'rails'
29
16
  gem 'kaminari'
30
17
 
31
18
  when Sinatra/Padrino:
32
19
  gem 'kaminari', :require => 'kaminari/sinatra'
33
20
 
34
- EOC
35
- end
36
-
37
- def self.load_kaminari!
38
- require 'kaminari/config'
39
- require 'kaminari/helpers/action_view_extension'
40
- require 'kaminari/helpers/paginator'
41
- require 'kaminari/models/page_scope_methods'
42
- require 'kaminari/models/configuration_methods'
43
- end
21
+ when Grape:
22
+ gem 'kaminari', :require => 'kaminari/grape'
44
23
 
45
- def self.hook!
46
- load_framework!
47
- load_kaminari!
48
- require 'kaminari/hooks'
49
- if rails?
50
- require 'kaminari/railtie'
51
- require 'kaminari/engine'
52
- elsif sinatra?
53
- require 'kaminari/sinatra'
54
- else
55
- Kaminari::Hooks.init!
56
- end
57
- end
24
+ EOC
58
25
 
59
- def self.load!
60
- hook!
61
- end
26
+ # load Kaminari components
27
+ require 'kaminari/config'
28
+ require 'kaminari/helpers/action_view_extension'
29
+ require 'kaminari/helpers/paginator'
30
+ require 'kaminari/models/page_scope_methods'
31
+ require 'kaminari/models/configuration_methods'
32
+ require 'kaminari/hooks'
62
33
 
63
- private
64
- def self.rails?
65
- defined?(::Rails)
66
- end
67
-
68
- def self.sinatra?
69
- defined?(::Sinatra)
70
- end
34
+ # if not using Railtie, call `Kaminari::Hooks.init` directly
35
+ if defined? Rails
36
+ require 'kaminari/railtie'
37
+ require 'kaminari/engine'
71
38
  end
72
-
73
- Kaminari.load!
@@ -18,21 +18,27 @@ module Kaminari
18
18
  class Configuration #:nodoc:
19
19
  include ActiveSupport::Configurable
20
20
  config_accessor :default_per_page
21
+ config_accessor :max_per_page
21
22
  config_accessor :window
22
23
  config_accessor :outer_window
23
24
  config_accessor :left
24
25
  config_accessor :right
25
26
  config_accessor :page_method_name
26
- config_accessor :param_name
27
27
 
28
28
  def param_name
29
29
  config.param_name.respond_to?(:call) ? config.param_name.call : config.param_name
30
30
  end
31
+
32
+ # define param_name writer (copied from AS::Configurable)
33
+ writer, line = 'def param_name=(value); config.param_name = value; end', __LINE__
34
+ singleton_class.class_eval writer, __FILE__, line
35
+ class_eval writer, __FILE__, line
31
36
  end
32
37
 
33
38
  # this is ugly. why can't we pass the default value to config_accessor...?
34
39
  configure do |config|
35
40
  config.default_per_page = 25
41
+ config.max_per_page = nil
36
42
  config.window = 4
37
43
  config.outer_window = 0
38
44
  config.left = 0
@@ -0,0 +1,4 @@
1
+ require 'grape'
2
+ require 'kaminari'
3
+
4
+ Kaminari::Hooks.init
@@ -15,10 +15,35 @@ module Kaminari
15
15
  # * <tt>:remote</tt> - Ajax? (false by default)
16
16
  # * <tt>:ANY_OTHER_VALUES</tt> - Any other hash key & values would be directly passed into each tag as :locals value.
17
17
  def paginate(scope, options = {}, &block)
18
- paginator = Kaminari::Helpers::Paginator.new self, options.reverse_merge(:current_page => scope.current_page, :num_pages => scope.num_pages, :per_page => scope.limit_value, :param_name => Kaminari.config.param_name, :remote => false)
18
+ paginator = Kaminari::Helpers::Paginator.new self, options.reverse_merge(:current_page => scope.current_page, :total_pages => scope.total_pages, :per_page => scope.limit_value, :param_name => Kaminari.config.param_name, :remote => false)
19
19
  paginator.to_s
20
20
  end
21
21
 
22
+ # A simple "Twitter like" pagination link that creates a link to the previous page.
23
+ #
24
+ # ==== Examples
25
+ # Basic usage:
26
+ #
27
+ # <%= link_to_previous_page @items, 'Previous Page' %>
28
+ #
29
+ # Ajax:
30
+ #
31
+ # <%= link_to_previous_page @items, 'Previous Page', :remote => true %>
32
+ #
33
+ # By default, it renders nothing if there are no more results on the previous page.
34
+ # You can customize this output by passing a block.
35
+ #
36
+ # <%= link_to_previous_page @users, 'Previous Page' do %>
37
+ # <span>At the Beginning</span>
38
+ # <% end %>
39
+ def link_to_previous_page(scope, name, options = {}, &block)
40
+ params = options.delete(:params) || {}
41
+ param_name = options.delete(:param_name) || Kaminari.config.param_name
42
+ link_to_unless scope.first_page?, name, params.merge(param_name => (scope.current_page - 1)), options.reverse_merge(:rel => 'previous') do
43
+ block.call if block
44
+ end
45
+ end
46
+
22
47
  # A simple "Twitter like" pagination link that creates a link to the next page.
23
48
  #
24
49
  # ==== Examples
@@ -55,26 +80,72 @@ module Kaminari
55
80
  #
56
81
  # By default, the message will use the humanized class name of objects
57
82
  # in collection: for instance, "project types" for ProjectType models.
83
+ # The namespace will be cutted out and only the last name will be used.
58
84
  # Override this with the <tt>:entry_name</tt> parameter:
59
85
  #
60
86
  # <%= page_entries_info @posts, :entry_name => 'item' %>
61
87
  # #-> Displaying items 6 - 10 of 26 in total
62
88
  def page_entries_info(collection, options = {})
63
- entry_name = options[:entry_name] || (collection.empty?? 'entry' : collection.first.class.name.underscore.sub('_', ' '))
64
- if collection.num_pages < 2
65
- case collection.total_count
66
- when 0; "No #{entry_name.pluralize} found"
67
- when 1; "Displaying <b>1</b> #{entry_name}"
68
- else; "Displaying <b>all #{collection.total_count}</b> #{entry_name.pluralize}"
89
+ entry_name = if options[:entry_name]
90
+ options[:entry_name]
91
+ elsif collection.empty? || collection.is_a?(PaginatableArray)
92
+ 'entry'
93
+ else
94
+ if collection.respond_to? :model # DataMapper
95
+ collection.model.model_name.human.downcase
96
+ else # AR
97
+ collection.model_name.human.downcase
69
98
  end
99
+ end
100
+ entry_name = entry_name.pluralize unless collection.total_count == 1
101
+
102
+ if collection.total_pages < 2
103
+ t('helpers.page_entries_info.one_page.display_entries', :entry_name => entry_name, :count => collection.total_count)
104
+ else
105
+ first = collection.offset_value + 1
106
+ last = collection.last_page? ? collection.total_count : collection.offset_value + collection.limit_value
107
+ t('helpers.page_entries_info.more_pages.display_entries', :entry_name => entry_name, :first => first, :last => last, :total => collection.total_count)
108
+ end.html_safe
109
+ end
110
+
111
+ # Renders rel="next" and rel="prev" links to be used in the head.
112
+ #
113
+ # ==== Examples
114
+ # Basic usage:
115
+ #
116
+ # In head:
117
+ # <head>
118
+ # <title>My Website</title>
119
+ # <%= yield :head %>
120
+ # </head>
121
+ #
122
+ # Somewhere in body:
123
+ # <% content_for :head do %>
124
+ # <%= rel_next_prev_link_tags @items %>
125
+ # <% end %>
126
+ #
127
+ # #-> <link rel="next" href="/items/page/3" /><link rel="prev" href="/items/page/1" />
128
+ #
129
+ def rel_next_prev_link_tags(scope, options = {})
130
+ params = options.delete(:params) || {}
131
+ param_name = options.delete(:param_name) || Kaminari.config.param_name
132
+
133
+ output = ""
134
+
135
+ if !scope.first_page? && !scope.last_page?
136
+ # If not first and not last, then output both links.
137
+ output << '<link rel="next" href="' + url_for(params.merge(param_name => (scope.current_page + 1))) + '"/>'
138
+ output << '<link rel="prev" href="' + url_for(params.merge(param_name => (scope.current_page - 1))) + '"/>'
139
+ elsif scope.first_page?
140
+ # If first page, add next link unless last page.
141
+ output << '<link rel="next" href="' + url_for(params.merge(param_name => (scope.current_page + 1))) + '"/>' unless scope.last_page?
70
142
  else
71
- offset = (collection.current_page - 1) * collection.limit_value
72
- %{Displaying #{entry_name.pluralize} <b>%d&nbsp;-&nbsp;%d</b> of <b>%d</b> in total} % [
73
- offset + 1,
74
- offset + collection.count,
75
- collection.total_count
76
- ]
143
+ # If last page, add prev link unless first page.
144
+ output << '<link rel="prev" href="' + url_for(params.merge(param_name => (scope.current_page - 1))) + '"/>' unless scope.first_page?
77
145
  end
146
+
147
+ output.html_safe
78
148
  end
149
+
79
150
  end
80
151
  end
@@ -23,13 +23,16 @@ module Kaminari
23
23
  @template, @options = template, options
24
24
  @theme = @options[:theme] ? "#{@options[:theme]}/" : ''
25
25
  @options[:current_page] = PageProxy.new @window_options.merge(@options), @options[:current_page], nil
26
+ #FIXME for compatibility. remove num_pages at some time in the future
27
+ @options[:total_pages] ||= @options[:num_pages]
28
+ @last = nil
26
29
  # initialize the output_buffer for Context
27
30
  @output_buffer = ActionView::OutputBuffer.new
28
31
  end
29
32
 
30
33
  # render given block as a view template
31
34
  def render(&block)
32
- instance_eval &block if @options[:num_pages] > 1
35
+ instance_eval(&block) if @options[:total_pages] > 1
33
36
  @output_buffer
34
37
  end
35
38
 
@@ -50,10 +53,10 @@ module Kaminari
50
53
 
51
54
  def relevant_pages(options)
52
55
  left_window_plus_one = 1.upto(options[:left] + 1).to_a
53
- right_window_plus_one = (options[:num_pages] - options[:right]).upto(options[:num_pages]).to_a
56
+ right_window_plus_one = (options[:total_pages] - options[:right]).upto(options[:total_pages]).to_a
54
57
  inside_window_plus_each_sides = (options[:current_page] - options[:window] - 1).upto(options[:current_page] + options[:window] + 1).to_a
55
58
 
56
- (left_window_plus_one + inside_window_plus_each_sides + right_window_plus_one).uniq.sort.reject {|x| (x < 1) || (x > options[:num_pages])}
59
+ (left_window_plus_one + inside_window_plus_each_sides + right_window_plus_one).uniq.sort.reject {|x| (x < 1) || (x > options[:total_pages])}
57
60
  end
58
61
  private :relevant_pages
59
62
 
@@ -114,7 +117,7 @@ module Kaminari
114
117
 
115
118
  # the last page or not
116
119
  def last?
117
- @page == @options[:num_pages]
120
+ @page == @options[:total_pages]
118
121
  end
119
122
 
120
123
  # the previous page or not
@@ -134,7 +137,7 @@ module Kaminari
134
137
 
135
138
  # within the right outer window or not
136
139
  def right_outer?
137
- @options[:num_pages] - @page < @options[:right]
140
+ @options[:total_pages] - @page < @options[:right]
138
141
  end
139
142
 
140
143
  # inside the inner window or not
@@ -14,8 +14,14 @@ module Kaminari::Helpers
14
14
 
15
15
  alias included registered
16
16
  end
17
-
17
+
18
18
  class ActionViewTemplateProxy
19
+ include Padrino::Helpers::OutputHelpers
20
+ include Padrino::Helpers::TagHelpers
21
+ include Padrino::Helpers::AssetTagHelpers
22
+ include Padrino::Helpers::FormatHelpers
23
+ include Padrino::Helpers::TranslationHelpers
24
+
19
25
  def initialize(opts={})
20
26
  @current_path = opts[:current_path]
21
27
  @param_name = (opts[:param_name] || :page).to_sym
@@ -38,12 +44,25 @@ module Kaminari::Helpers
38
44
  query = @current_params.merge(extra_params)
39
45
  @current_path + (query.empty? ? '' : "?#{query.to_query}")
40
46
  end
41
-
47
+
48
+ def link_to_unless(condition, name, options = {}, html_options = {}, &block)
49
+ options = url_for(options) if options.is_a? Hash
50
+ if condition
51
+ if block_given?
52
+ block.arity <= 1 ? capture(name, &block) : capture(name, options, html_options, &block)
53
+ else
54
+ name
55
+ end
56
+ else
57
+ link_to(name, options, html_options)
58
+ end
59
+ end
60
+
42
61
  def params
43
62
  @current_params
44
63
  end
45
64
  end
46
-
65
+
47
66
  module HelperMethods
48
67
  # A helper that renders the pagination links - for Sinatra.
49
68
  #
@@ -63,7 +82,7 @@ module Kaminari::Helpers
63
82
  current_params = Rack::Utils.parse_query(env['QUERY_STRING']).symbolize_keys rescue {}
64
83
  paginator = Kaminari::Helpers::Paginator.new(
65
84
  ActionViewTemplateProxy.new(:current_params => current_params, :current_path => current_path, :param_name => options[:param_name] || Kaminari.config.param_name),
66
- options.reverse_merge(:current_page => scope.current_page, :num_pages => scope.num_pages, :per_page => scope.limit_value, :param_name => Kaminari.config.param_name, :remote => false)
85
+ options.reverse_merge(:current_page => scope.current_page, :total_pages => scope.total_pages, :per_page => scope.limit_value, :param_name => Kaminari.config.param_name, :remote => false)
67
86
  )
68
87
  paginator.to_s
69
88
  end
@@ -88,10 +107,10 @@ module Kaminari::Helpers
88
107
  def link_to_next_page(scope, name, options = {})
89
108
  params = options.delete(:params) || (Rack::Utils.parse_query(env['QUERY_STRING']).symbolize_keys rescue {})
90
109
  param_name = options.delete(:param_name) || Kaminari.config.param_name
91
- placeholder = options.delete(:placeholder) || ""
110
+ placeholder = options.delete(:placeholder)
92
111
  query = params.merge(param_name => (scope.current_page + 1))
93
112
  unless scope.last_page?
94
- link_to name, env['PATH_INFO'] + (query.empty? ? '' : "?#{query.to_query}"), options.merge(:rel => 'next')
113
+ link_to name, env['PATH_INFO'] + (query.empty? ? '' : "?#{query.to_query}"), options.reverse_merge(:rel => 'next')
95
114
  else
96
115
  placeholder
97
116
  end