开发者

Pagination error in Ruby

开发者 https://www.devze.com 2023-03-21 20:38 出处:网络
In my ror app I would like to use pagination. For that I have used a method in my helper def show_pagination_links(base_url, page_key, page_num, list_size, per_page)

In my ror app I would like to use pagination.

For that I have used a method in my helper

def show_pagination_links(base_url, page_key, page_num, list_size, per_page)

html = ""
append_key = (base_url.include?"?") ? ("&" + page_key) : ("?" + page_key)
html += "<a href='" + base_url + append_key + "=" + (page_num - 1).to_s + "'>&laquo; Prev</a> &nbsp; |&nbsp;  " if page_num > 1
html += "<a href='" + base_url + append_key + "=" + (page_num + 1).to_s + "'>Next &raquo;</a>" if list_size >= per_page
html
end

In the controller I have used

@return_value.paginate(:page => @pageno, :per_page => @per_p开发者_如何学Pythonage, :descending => true)

Where @return_value is the return value from my db (mysql)

in view

<%= show_pagination_links(@my_events_url, 'page', @pageno.to_i, @return_value.size, @per_page).html_safe %>

but am getting error as

undefined method `paginate' for #

I don't know how to solve it ... pls any one help me


Have you included the will_paginate gem in your gemfile?


You should use will_paginate

0

精彩评论

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