Module: RailsPaginate::Helpers::ActionView

Defined in:
lib/rails_paginate/helpers/action_view.rb

Overview

ActionView extension for create paginate view helper

Instance Method Summary collapse

Instance Method Details

#paginate(*args) ⇒ Object

view_helper for paginate

Options

:id :class

Raises:

  • (ArgumentError)


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/rails_paginate/helpers/action_view.rb', line 9

def paginate(*args)
  options = args.extract_options!

  raise ArgumentError, "first argument must be a RailsPaginate::Collection" unless args.first.is_a? RailsPaginate::Collection

  collection = args.first
#      p @controller
#      p url_for(:action => :index, :controller => :dummy)

  # renderer
  renderer = options[:renderer] || RailsPaginate.default_renderer
  pager = options[:pager] || RailsPaginate.default_pager

  attributes = {}
  attributes[:class] = "pagination #{options[:class]}".strip
  attributes[:id] = options[:id] unless options[:id].blank?

  # load classes
  renderer = RailsPaginate.renderer(renderer)
  pager = RailsPaginate.pager(pager)

   :div, attributes do
    renderer.new(self, collection, pager.new(collection), options).render
  end
end