Sha256: b7f321fa9f101cbb12b4a1dbd2737e5799434772a8ab2195cbf50605c4868fe9

Contents?: true

Size: 878 Bytes

Versions: 1

Compression:

Stored size: 878 Bytes

Contents

# encoding: utf-8

module SportDbAdmin

class GamesController < ApplicationController

  # GET /games
  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
  
  # GET /games/past
  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

end # class GamesController

end # module SportDbAdmin

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sportdb-admin-0.1.0 app/controllers/sport_db_admin/games_controller.rb