class LeaguesController < ApplicationController def index @leagues = League.all end def show league_id = params[:id] @league = League.find_by(league_id: league_id) @q = LeaguePickScore.where(league_id: league_id).ransack(params[:q]) @q.sorts = 'total desc' if @q.sorts.empty? @scores = @q.result(distinct: true) @player_scores = PlayerScore.where(league_id: league_id) end end