开发者

how to use will paginate helpers in my own helper

开发者 https://www.devze.com 2023-02-23 06:40 出处:网络
Hi i cre开发者_如何转开发ated my own helper and passed the array of objects to it. And from there i want to get the pagination results.

Hi i cre开发者_如何转开发ated my own helper and passed the array of objects to it. And from there i want to get the pagination results.

def processed_pagination
    content_tag(:div, will_paginate(@object), :class=>"list-pagination")
end

but it is generating error

ActionView::Template::Error (undefined method 'get?' for nil:NilClass):

I also tried to include in the class

include ActionView::Helpers::UrlHelper
include Rails.application.routes.url_helpers

but no way, error is still there.

Can any one guide me.


Can you try passing @object to your helper method?

def processed_pagination(@object)
    content_tag(:div, will_paginate(@object), :class=>"list-pagination")
end

In your view you can do:

processed_pagination(@object)
0

精彩评论

暂无评论...
验证码 换一张
取 消