如何在merb中为will_paginate添加自定义渲染器?

时间:2015-12-14 17:22:15

标签: html ruby-on-rails ruby will-paginate merb

因为我需要以这种方式完成分页标记:

<ul> <li> <a>some page</a> </li> </ul>

我想将自定义渲染器添加到Merb应用。当我把代码

module SearchPagination
  class LinkRenderer < WillPaginate::ActionView::LinkRenderer
    protected
    def windowed_page_numbers
      inner_window = @options[:inner_window].to_i
      window_from = current_page
      window_to = current_page + inner_window

      # adjust upper limit if out of bounds
      window_to = total_pages if window_to > total_pages
      left = (window_from..window_to).to_a
      left << :gap if total_pages > window_to
      left
   end
 end

进入helpers / paginate_helper.rb,然后在视图中使用它:

<%= will_paginate @channels, :renderer => SearchPagination::LinkRenderer %>

我收到了下一个错误:

uninitialized constant Merb::InlineTemplates::SearchPagination - (NameError)

那么,如何以正确的方式连接这些东西?

0 个答案:

没有答案