ArgumentError #227

Closed
phunold opened this Issue Feb 29, 2012 · 3 comments

Comments

Projects
None yet
2 participants

phunold commented Feb 29, 2012

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

phunold commented Mar 2, 2012

Hey, does anyone have a comment on the issue I encounter?
Any hint where the issue may be is appreciated.

Thanks.

Owner

mislav commented Mar 7, 2012

Sequel already supports pagination and has its own paginate method, which will_paginate doesn't try to change. I understand how you got confused, but it's in the philosophy of will_paginate not to override any existing functionality of the ORM. You'll just have to remember you're using Sequel's paginate method, not that of will_paginate.

The updated code:

@items = DB[:items].order(:created_at).paginate(params[:page], 30)

@mislav mislav closed this Mar 7, 2012

phunold commented Mar 7, 2012

Thank you Mislav.
I appreciate the comment.

On Wed, Mar 7, 2012 at 1:17 PM, Mislav Marohnić
reply@reply.github.com
wrote:

Sequel already supports pagination and has its own paginate method, which will_paginate doesn't try to change. I understand how you got confused, but it's in the philosophy of will_paginate not to override any existing functionality of the ORM. You'll just have to remember you're using Sequel's paginate method, not that of will_paginate.

The updated code:

@items = DB[:items].order(:created_at).paginate(params[:page], 30)

Reply to this email directly or view it on GitHub:
#227 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment