mislav/will_paginate — Issue #227: ArgumentError
Author: phunold
Created: 2012-02-29 05:49:44+00:00
State: open

I did check Google Group and Troubleshooting guide for similar error, but nothing seems to apply here.
I hope it's not a silly version incompatibility issue between sinatra and will_paginate.

Getting Argument Error, wrong number of argument (1 for 2)

Trying to use will_paginate in Sinatra(1.2.6), Sequel, Haml
will_paginate is version: 3.0.3

Error Code
== Sinatra/1.2.6 has taken the stage on 4567 for development with backup from WEBrick
[2012-02-29 00:28:55] INFO WEBrick 1.3.1
[2012-02-29 00:28:55] INFO ruby 1.8.7 (2011-06-30) [x86_64-linux]
[2012-02-29 00:29:00] INFO WEBrick::HTTPServer#start: pid=9433 port=4567
3.0.3
ArgumentError - wrong number of arguments (1 for 2):
app.rb:18:in `paginate'
app.rb:18:in `GET /'
/usr/lib/ruby/vendor_ruby/sinatra/base.rb:1151:in `call'
/usr/lib/ruby/vendor_ruby/sinatra/base.rb:1151:in `compile!'
/usr/lib/ruby/vendor_ruby/sinatra/base.rb:724:in `instance_eval'
/usr/lib/ruby/vendor_ruby/sinatra/base.rb:724:in `route_eval'
/usr/lib/ruby/vendor_ruby/sinatra/base.rb:708:in `route!'
/usr/lib/ruby/vendor_ruby/sinatra/base.rb:758:in `process_route'
/usr/lib/ruby/vendor_ruby/sinatra/base.rb:755:in `catch'
/usr/lib/ruby/vendor_ruby/sinatra/base.rb:755:in `process_route'
/usr/lib/ruby/vendor_ruby/sinatra/base.rb:707:in `route!'
/usr/lib/ruby/vendor_ruby/sinatra/base.rb:706:in `each'
/usr/lib/ruby/vendor_ruby/sinatra/base.rb:706:in `route!'
/usr/lib/ruby/vendor_ruby/sinatra/base.rb:843:in `dispatch!'
/usr/lib/ruby/vendor_ruby/sinatra/base.rb:644:in `call!'
/usr/lib/ruby/vendor_ruby/sinatra/base.rb:808:in `instance_eval'
/usr/lib/ruby/vendor_ruby/sinatra/base.rb:808:in `invoke'
/usr/lib/ruby/vendor_ruby/sinatra/base.rb:808:in `catch'
/usr/lib/ruby/vendor_ruby/sinatra/base.rb:808:in `invoke'
/usr/lib/ruby/vendor_ruby/sinatra/base.rb:644:in `call!'
/usr/lib/ruby/vendor_ruby/sinatra/base.rb:629:in `call'
/usr/lib/ruby/1.8/rack/head.rb:9:in `call'
/usr/lib/ruby/1.8/rack/commonlogger.rb:18:in `call'
/usr/lib/ruby/vendor_ruby/sinatra/showexceptions.rb:21:in `call'
/usr/lib/ruby/1.8/rack/methodoverride.rb:24:in `call'
/usr/lib/ruby/vendor_ruby/sinatra/base.rb:1272:in `call'
/usr/lib/ruby/vendor_ruby/sinatra/base.rb:1303:in `synchronize'
/usr/lib/ruby/vendor_ruby/sinatra/base.rb:1272:in `call'
/usr/lib/ruby/1.8/rack/content_length.rb:13:in `call'
/usr/lib/ruby/1.8/rack/handler/webrick.rb:48:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
/usr/lib/ruby/1.8/rack/handler/webrick.rb:14:in `run'
/usr/lib/ruby/vendor_ruby/sinatra/base.rb:1234:in `run!'
/usr/lib/ruby/vendor_ruby/sinatra/main.rb:25

app.rb:

#!/usr/bin/env ruby
require 'sinatra'
require 'rubygems'
require 'sequel'
require 'haml'
require 'will_paginate'
require 'will_paginate/sequel'
require 'will_paginate/version'

# connect to database
DB = Sequel.mysql 'mydb', :user=>'test', :host=>'localhost', :password=>'test'

get '/' do
puts WillPaginate::VERSION::STRING
@items = DB[:items].order(:created_at)
@items = @items.paginate :page => params[:page], :per_page => 30
haml :test
end

view 'test.haml':
= will_paginate @test

That's it.
I hope someone can enlighten me.
Thanks in advance.
Philipp