SCENARIO: I have a Pictures table that contains hundreds of photos. I\'m currently using \'will_paginate\' to paginate 100 photos per page. I would like to
You cannot use will paginate by group/scope by date. You'll need to do this yourself. It's not terribly difficult though, you could do something like this:
# pictures_controller.rb
def index
@date = Date.parse(params[:date]) rescue Date.today
@pictures = Picture.where(:created_at => @date.at_midnight..@date.next_day.at_midnight)
@total_pictures = Picture.count
@current_pictures = @pictures.size
end
# pictures/index.html.haml
- @pictures.each do |picture|
= #....
= "Showing #{@current_pictures} pictures for #{@date}."
= "There are a total of #{@total_pictures} pictures."
= link_to 'View Previous day photos', pictures_url(:date => @date.prev_day)
- if @date.past?
= link_to 'View Next day photos', pictures_url(:date => @date.next_day)