pager-api icon indicating copy to clipboard operation
pager-api copied to clipboard

undefined method `each' for 1:Fixnum

Open Meekohi opened this issue 7 years ago • 4 comments

def index
  paginate Loan.unscoped
end
Started GET "/loans" for 127.0.0.1 at 2017-04-05 11:31:31 -0400
Processing by LoansController#index as */*
  Parameters: {"loan"=>{}}
  CACHE (0.0ms)  SELECT COUNT(*) FROM "loans"
  CACHE (0.0ms)  SELECT  "loans".* FROM "loans" LIMIT $1 OFFSET $2  [["LIMIT", 25], ["OFFSET", 0]]
Completed 200 OK in 129ms (Views: 127.6ms | ActiveRecord: 0.0ms)


Unexpected error while processing request: undefined method `each' for 1:Fixnum
  /thin-1.7.0/lib/thin/response.rb:74:in `block in headers='
  /rack-2.0.1/lib/rack/utils.rb:454:in `block in each'
  /rack-2.0.1/lib/rack/utils.rb:453:in `each'
  /rack-2.0.1/lib/rack/utils.rb:453:in `each'
  /thin-1.7.0/lib/thin/response.rb:69:in `headers='
  /thin-1.7.0/lib/thin/connection.rb:102:in `post_process'
  /thin-1.7.0/lib/thin/connection.rb:53:in `process'
  /thin-1.7.0/lib/thin/connection.rb:39:in `receive_data'
  /eventmachine-1.2.2/lib/eventmachine.rb:194:in `run_machine'
  /eventmachine-1.2.2/lib/eventmachine.rb:194:in `run'
  /thin-1.7.0/lib/thin/backends/base.rb:73:in `start'
  /thin-1.7.0/lib/thin/server.rb:162:in `start'
  /rack-2.0.1/lib/rack/handler/thin.rb:22:in `run'
  /rack-2.0.1/lib/rack/server.rb:296:in `start'
  /railties-5.0.0.1/lib/rails/commands/server.rb:79:in `start'
  /railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:90:in `block in server'
  /railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:85:in `tap'
  /railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:85:in `server'
  /railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
  /railties-5.0.0.1/lib/rails/commands.rb:18:in `<top (required)>'
  /bin/rails:9:in `require'
  /bin/rails:9:in `<top (required)>'
  /spring-2.0.0/lib/spring/client/rails.rb:28:in `load'
  /spring-2.0.0/lib/spring/client/rails.rb:28:in `call'
  /spring-2.0.0/lib/spring/client/command.rb:7:in `call'
  /spring-2.0.0/lib/spring/client.rb:30:in `run'
  /spring-2.0.0/bin/spring:49:in `<top (required)>'
  /spring-2.0.0/lib/spring/binstub.rb:31:in `load'
  /spring-2.0.0/lib/spring/binstub.rb:31:in `<top (required)>'
  /bin/spring:14:in `require'
  /bin/spring:14:in `<top (required)>'
  bin/rails:3:in `load'
  bin/rails:3:in `<main>'

Meekohi avatar Apr 05 '17 15:04 Meekohi

@Meekohi, I think here he problem is not in this gem. pls show me what return Loan.unscoped

frostmark avatar Apr 07 '17 12:04 frostmark

Loan is just a pretty standard ActiveRecord model. This is ruby 2.4.1, rails 4.2.8, not sure if that would matter.

paginate Loan.unscoped, per_page: 5

gives undefined methodeach' for 5:Fixnum` so seems related to the per_page parameter.

Meekohi avatar Apr 07 '17 13:04 Meekohi

Have you tried with another scope? just to see if it is the actual collection...

kurenn avatar Apr 07 '17 20:04 kurenn

Which handler of pagination are you using?

kurenn avatar Jun 05 '18 18:06 kurenn