Permalink
Browse files

[gem] Added pagination via the will_paginate gem. Vanquished a wild TODO

  • Loading branch information...
1 parent 73d7b66 commit 42ea9819a75aa0a4c5ccaeb34dd941dc2c47f51a @reidab reidab committed Mar 6, 2011
View
@@ -5,6 +5,7 @@ gem "capybara", ">= 0.4.0"
gem "sqlite3-ruby", :require => "sqlite3"
gem "haml", "~> 3.0.0"
gem "paper_trail", "~> 2.0"
+gem "will_paginate", "~> 3.0.pre2"
gem "rspec-rails", "~> 2.5.0"
gem "factory_girl_rails", "~> 1.1.beta1"
View
@@ -123,6 +123,7 @@ GEM
treetop (1.4.9)
polyglot (>= 0.3.1)
tzinfo (0.3.24)
+ will_paginate (3.0.pre2)
xpath (0.1.3)
nokogiri (~> 1.3)
@@ -140,3 +141,4 @@ DEPENDENCIES
ruby-debug
spork (~> 0.9.0.rc)
sqlite3-ruby
+ will_paginate (~> 3.0.pre2)
View
@@ -35,6 +35,7 @@ Jeweler::Tasks.new do |gem|
gem.homepage = "http://github.com/igal/paper_trail_manager"
gem.add_dependency "paper_trail", "~> 2"
gem.add_dependency("haml", "~> 3.0.0")
+ gem.add_dependency("will_paginate", "~> 3.0.pre2")
end
namespace :spork do
@@ -6,15 +6,16 @@ def index
return(redirect_to root_url)
end
- # TODO add pagination
- # @versions = Version.paginate(:page => params[:page], :order => 'created_at DESC', :per_page => 50)
@versions = Version.order('created_at DESC, id DESC')
if params[:type]
@versions = @versions.where(:item_type => params[:type])
end
if params[:id]
@versions = @versions.where(:item_id => params[:id])
end
+
+ @versions = @versions.paginate(:page => params[:page], :per_page => 50)
+
respond_to do |format|
format.html # index.html.erb
format.atom # index.atom.builder
@@ -8,13 +8,19 @@
!= ([link_to('All', changes_path)] + change_item_types.map { |type| link_to(type.pluralize, changes_path(:type => type)) }).join(' | ')
%table.changes_table
- %tr.changes_header
- %th.change_time Time
- %th.change_details Attribute with previous and current values
- - if @versions.any?
- - @versions.each do |version|
- - next unless change_show_allowed?(version)
- = render :partial => 'version', :object => version
- - else
- %td{:rowspan => 2}
- — No changes found —
+ %tfoot
+ %tr
+ %td{:colspan => 2}
+ = will_paginate @versions
+ %thead
+ %tr.changes_header
+ %th.change_time Time
+ %th.change_details Attribute with previous and current values
+ %tbody
+ - if @versions.any?
+ - @versions.each do |version|
+ - next unless change_show_allowed?(version)
+ = render :partial => 'version', :object => version
+ - else
+ %td{:rowspan => 2}
+ — No changes found —
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Igal Koshevoy"]
- s.date = %q{2011-02-28}
+ s.date = %q{2011-03-05}
s.description = %q{A user interface for `paper_trail` versioning data in Ruby on Rails 3 applications.}
s.email = %q{igal@pragmaticraft.com}
s.extra_rdoc_files = [
@@ -108,7 +108,7 @@ Gem::Specification.new do |s|
]
s.homepage = %q{http://github.com/igal/paper_trail_manager}
s.require_paths = ["lib"]
- s.rubygems_version = %q{1.3.7}
+ s.rubygems_version = %q{1.4.1}
s.summary = %q{A user interface for `paper_trail` versioning data in Ruby on Rails 3 applications.}
s.test_files = [
"spec/controllers/paper_trail_manager/changes_controller_spec.rb",
@@ -162,7 +162,6 @@ Gem::Specification.new do |s|
]
if s.respond_to? :specification_version then
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
s.specification_version = 3
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
@@ -171,40 +170,46 @@ Gem::Specification.new do |s|
s.add_runtime_dependency(%q<sqlite3-ruby>, [">= 0"])
s.add_runtime_dependency(%q<haml>, ["~> 3.0.0"])
s.add_runtime_dependency(%q<paper_trail>, ["~> 2.0"])
+ s.add_runtime_dependency(%q<will_paginate>, ["~> 3.0.pre2"])
s.add_runtime_dependency(%q<rspec-rails>, ["~> 2.5.0"])
s.add_runtime_dependency(%q<factory_girl_rails>, ["~> 1.1.beta1"])
s.add_runtime_dependency(%q<spork>, ["~> 0.9.0.rc"])
s.add_runtime_dependency(%q<jeweler>, ["~> 1.5.2"])
s.add_runtime_dependency(%q<ruby-debug>, [">= 0"])
s.add_runtime_dependency(%q<paper_trail>, ["~> 2"])
s.add_runtime_dependency(%q<haml>, ["~> 3.0.0"])
+ s.add_runtime_dependency(%q<will_paginate>, ["~> 3.0.pre2"])
else
s.add_dependency(%q<rails>, ["~> 3.0.3"])
s.add_dependency(%q<capybara>, [">= 0.4.0"])
s.add_dependency(%q<sqlite3-ruby>, [">= 0"])
s.add_dependency(%q<haml>, ["~> 3.0.0"])
s.add_dependency(%q<paper_trail>, ["~> 2.0"])
+ s.add_dependency(%q<will_paginate>, ["~> 3.0.pre2"])
s.add_dependency(%q<rspec-rails>, ["~> 2.5.0"])
s.add_dependency(%q<factory_girl_rails>, ["~> 1.1.beta1"])
s.add_dependency(%q<spork>, ["~> 0.9.0.rc"])
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
s.add_dependency(%q<ruby-debug>, [">= 0"])
s.add_dependency(%q<paper_trail>, ["~> 2"])
s.add_dependency(%q<haml>, ["~> 3.0.0"])
+ s.add_dependency(%q<will_paginate>, ["~> 3.0.pre2"])
end
else
s.add_dependency(%q<rails>, ["~> 3.0.3"])
s.add_dependency(%q<capybara>, [">= 0.4.0"])
s.add_dependency(%q<sqlite3-ruby>, [">= 0"])
s.add_dependency(%q<haml>, ["~> 3.0.0"])
s.add_dependency(%q<paper_trail>, ["~> 2.0"])
+ s.add_dependency(%q<will_paginate>, ["~> 3.0.pre2"])
s.add_dependency(%q<rspec-rails>, ["~> 2.5.0"])
s.add_dependency(%q<factory_girl_rails>, ["~> 1.1.beta1"])
s.add_dependency(%q<spork>, ["~> 0.9.0.rc"])
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
s.add_dependency(%q<ruby-debug>, [">= 0"])
s.add_dependency(%q<paper_trail>, ["~> 2"])
s.add_dependency(%q<haml>, ["~> 3.0.0"])
+ s.add_dependency(%q<will_paginate>, ["~> 3.0.pre2"])
end
end

0 comments on commit 42ea981

Please sign in to comment.