Class: SportDbAdmin::GamesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/sport_db_admin/games_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject

GET /games



8
9
10
11
12
13
14
# File 'app/controllers/sport_db_admin/games_controller.rb', line 8

def index
  # find next upcoming games
  limit = params[:limit] || '50'
  
  @games = Game.where( 'play_at > ?', Time.now ).order( 'play_at').limit(limit)
  @show_upcoming = true
end

#pastObject

GET /games/past



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/controllers/sport_db_admin/games_controller.rb', line 17

def past
  limit = params[:limit] || '50'
  
  if params[:null].present?   # e.g. use ?null=t
    ## find all past games w/ missing score
    @games = Game.where( 'play_at < ?', Time.now ).
                  where( 'score1 is null or score2 is null').
                  order( 'play_at desc').limit(limit)
  else
    @games = Game.where( 'play_at < ?', Time.now ).order( 'play_at desc').limit(limit)
  end
  
  @show_upcoming = false
  
  render :action => 'index'
end