ruby-on-railsruby-on-rails-3merit-gem

Rails 3: Merit Gem to show records by seasons through dropdown button


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


Solution

  • 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.