will_paginate undefined method `total_pages'

后端 未结 5 1955
失恋的感觉
失恋的感觉 2020-12-13 12:36

What am I missing here? I am using the haml_scaffold generator and the pages work fine with will_paginate. When I start tinkering I end up with this \'total_pages\' error an

5条回答
  •  情书的邮戳
    2020-12-13 13:07

    If anyone else is having this problem. In my case I did not call the pagination in my controller method last.

    Example Before:

    @foo = Foo.paginate(:page => params[:page], :per_page => 15)
    @foo = Foo.do something
    

    Example After: I called the pagination last within my method since rails reads from top to bottom and it seemed to fix my error.

    @foo = Foo.do something
    @foo = Foo.paginate(:page => params[:page], :per_page => 15)
    

提交回复
热议问题