I have a model, target, that holds a number of records that are timestamped. On the corresponding controller, I list the months of those records by doing the following:
In models/target.rb
def month
self.recorded_on.strftime('%B')
end
In controllers/targets_controller.rb
@records = Target.find :all
In views/targets/index.html.haml
%ul
- @records.group_by(&:month).sort.each do |month, data|
%li= link_to month, ''
That all works great for listing the available months for the records that I have. Next, I want to be able to click on the month and get a report of all the records for that month, at the following path generated with year and the month: /targets/2009/04
How would I do this?