Forum: Ruby on Rails paginate_by_sql giving errors

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
D8f444b5c1b0304a2b98d5b16da0f2f1?d=identicon&s=25 Jeba Momin (zeba)
on 2009-01-16 07:27
Hi,
I'm using paginate_by_sql to have pagination for my list views as my
queries have joins on multiple tables.
I have included the code into my application.rb , and in the controller
I have:

@discipline_pages, @disciplines = paginate_by_sql(Discipline,query,2)

But I get error as:

wrong number of arguments (4 for 2)

app/controllers/application.rb:63:in `initialize'
app/controllers/application.rb:63:in `new'
app/controllers/application.rb:63:in `paginate_by_sql'
app/controllers/discipline_controller.rb:140:in `list'

At application.rb:63 I have:

object_pages = Paginator.new self, total, per_page,params['page']

Please can someone help me with this...
Thanks in advance.
D8f444b5c1b0304a2b98d5b16da0f2f1?d=identicon&s=25 Jeba Momin (zeba)
on 2009-01-16 08:05
Hey,
I was able to solve the earlier error by changing application.rb:63 to:
object_pages = Paginator.new self, total, per_page,@params['page']

But now I have another error which says...

You have a nil object when you didn't expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.[]

app/controllers/application.rb:63:in `paginate_by_sql'
app/controllers/discipline_controller.rb:140:in `list'

Where am I going wrong...
Can someone please help...
Thanks.


Jeba Momin wrote:
> Hi,
> I'm using paginate_by_sql to have pagination for my list views as my
> queries have joins on multiple tables.
> I have included the code into my application.rb , and in the controller
> I have:
>
> @discipline_pages, @disciplines = paginate_by_sql(Discipline,query,2)
>
> But I get error as:
>
> wrong number of arguments (4 for 2)
>
> app/controllers/application.rb:63:in `initialize'
> app/controllers/application.rb:63:in `new'
> app/controllers/application.rb:63:in `paginate_by_sql'
> app/controllers/discipline_controller.rb:140:in `list'
>
> At application.rb:63 I have:
>
> object_pages = Paginator.new self, total, per_page,params['page']
>
> Please can someone help me with this...
> Thanks in advance.
This topic is locked and can not be replied to.