You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This happens when calling page_entries_info with a collection created with .page().per() by passing a String to .per().
If the collection was created by passing an integer to .per() it all works fine.
Solution
I have found that changing this line to this fixes the issue:
@_per=num.to_i
Also, as a temporary solution I can cast the argument passed to .per() to an integer.
Steps to replicate
This fails:
includeKaminari::Helpers::HelperMethodscollection=User.page(1).per("5")# passing a String to .per()page_entries_info(collection)# raises: ArgumentError: comparison of Fixnum with String failed
This works fine:
includeKaminari::Helpers::HelperMethodscollection=User.page(1).per(5)# passing a Fixnum to .per()page_entries_info(collection)# this will trigger an error because translation module is not included, but the method works as expected
Stack trace
ArgumentError: comparison of Fixnum with String failed
from /Users/rafaelgonzalez/.rvm/gems/ruby-2.3.3/gems/kaminari-activerecord-1.0.0/lib/kaminari/activerecord/active_record_relation_methods.rb:25:in `<'
from /Users/rafaelgonzalez/.rvm/gems/ruby-2.3.3/gems/kaminari-activerecord-1.0.0/lib/kaminari/activerecord/active_record_relation_methods.rb:25:in `total_count'
from /Users/rafaelgonzalez/.rvm/gems/ruby-2.3.3/gems/kaminari-core-1.0.0/lib/kaminari/models/page_scope_methods.rb:36:in `total_pages'
from /Users/rafaelgonzalez/.rvm/gems/ruby-2.3.3/gems/kaminari-core-1.0.0/lib/kaminari/helpers/helper_methods.rb:107:in `page_entries_info'
from (irb):5
from /Users/rafaelgonzalez/.rvm/gems/ruby-2.3.3/gems/railties-4.2.7.1/lib/rails/commands/console.rb:110:in `start'
from /Users/rafaelgonzalez/.rvm/gems/ruby-2.3.3/gems/railties-4.2.7.1/lib/rails/commands/console.rb:9:in `start'
from /Users/rafaelgonzalez/.rvm/gems/ruby-2.3.3/gems/railties-4.2.7.1/lib/rails/commands/commands_tasks.rb:68:in `console'
from /Users/rafaelgonzalez/.rvm/gems/ruby-2.3.3/gems/railties-4.2.7.1/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /Users/rafaelgonzalez/.rvm/gems/ruby-2.3.3/gems/railties-4.2.7.1/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:8:in `require'
from bin/rails:8:in `<main>'
The text was updated successfully, but these errors were encountered:
Description
This happens when calling
page_entries_info
with a collection created with.page().per()
by passing aString
to.per()
.If the collection was created by passing an integer to
.per()
it all works fine.Solution
I have found that changing this line to this fixes the issue:
Also, as a temporary solution I can cast the argument passed to
.per()
to an integer.Steps to replicate
This fails:
This works fine:
Stack trace
The text was updated successfully, but these errors were encountered: