0
class StaticPagesController < ApplicationController
 def home

 end

 def leaderboard
   @scores = Merit::Score.top_scored
 end
end

I am using the merit system for my ruby on rails application and i want to show records by seasons (Summer, Fall, Winter) through an action of a button.

New to rails and first time I've ran into an occasion where I can't find the answer already posted online.

Using this code here for the leaderboard: https://github.com/tute/merit/wiki/How-to-show-a-points-leaderboard

arinh
  • 206
  • 1
  • 12
  • Read about ActiveRecord Querying (http://guides.rubyonrails.org/active_record_querying.html) and especially the `group` method. – joelparkerhenderson May 19 '14 at 23:08
  • I understand the majority of the querying, but is there a way to call these "groups" based on an action of a button? Like "View by" dropdown > Summer 2014. – arinh May 20 '14 at 18:14

1 Answers1

0

I solved the issue by using this code in my static page controller:

def leaderboard
since_date = params[:since_date]
end_date = params[:end_date]
  if since_date.blank? && end_date.blank?
      @scores = Merit::Score.top_scored
  else
      @scores = Merit::Score.top_scored(since_date: since_date, end_date: end_date)
end

and creating an end date in top scored. Then passing the params within the link.

arinh
  • 206
  • 1
  • 12