Files
danbooru/app/logical/post_sets/sequential.rb
albert f67374da83 * 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.
2011-06-07 19:06:39 -04:00

30 lines
580 B
Ruby

module PostSets
module Sequential
def before_id
params[:before_id]
end
def after_id
params[:after_id]
end
def slice(relation)
if before_id
relation.where("id < ?", before_id).limit(limit).all
elsif after_id
relation.where("id > ?", after_id).order("id asc").limit(limit).all.reverse
else
relation.limit(limit).all
end
end
def pagination_options
{:before_id => before_id, :after_id => after_id}
end
def is_first_page?
before_id.nil?
end
end
end