* Some major bug fixes related to post sets. Tests for pools and favorites were added.

* Refactored the favorites code a bit. Adding a favorite from either an user or a post now works and will update all necessary records.
This commit is contained in:
albert
2011-06-07 19:06:39 -04:00
parent 49b3d43ddd
commit f67374da83
14 changed files with 215 additions and 70 deletions

View File

@@ -1,12 +1,5 @@
module PostSets
module Numbered
attr_reader :page
def initialize(params)
super
@page = options[:page] ? options[:page].to_i : 1
end
def total_pages
@total_pages ||= (count / limit.to_f).ceil.to_i
end
@@ -17,7 +10,7 @@ module PostSets
end
def slice(relation)
relation.offset(offset).all
relation.offset(offset).limit(limit).all
end
def pagination_options
@@ -28,6 +21,10 @@ module PostSets
offset == 0
end
def page
@page ||= params[:page] ? params[:page].to_i : 1
end
def offset
((page < 1) ? 0 : (page - 1)) * limit
end