Sha256: e707df6f209aefa26c85b709ef8cbad3adbfc4ab29864768cdaec6b4be982006

Contents?: true

Size: 1007 Bytes

Versions: 4

Compression:

Stored size: 1007 Bytes

Contents

# encoding: utf-8

module SportDbAdmin

class TeamsController < SportDbAdminController

  # GET /teams
  def index
    # make clubs default view
    index_clubs
  end

  def index_national_teams
    # todo: join country table to order by country.key ??
    @teams = Team.where( club: false ).order( 'country_id' ).all
  end

  def index_clubs
    @teams = Team.where( club: true )
    
    if params[:order].present?
      if params[:order] == 'key'
        @teams = @teams.order( 'key' )
      elsif params[:order] == 'title'
        @teams = @teams.order( 'title' )
      elsif params[:order] == 'code'
        @teams = @teams.order( 'code' )
      end
    else
      @teams = @teams.order( 'country_id' )
    end
    
    @teams = @teams.all
  end

  # GET /:key  e.g  /barcelona or /rapid etc.
  def shortcut
    @team = Team.find_by_key!( params[:key] )
    render :show
  end

  # GET /teams/1
  def show
    @team = Team.find(params[:id])
  end

end # class TeamsController

end # module SportDbAdmin

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sportdb-admin-0.4.0 app/controllers/sport_db_admin/teams_controller.rb
sportdb-admin-0.3.0 app/controllers/sport_db_admin/teams_controller.rb
sportdb-admin-0.2.0 app/controllers/sport_db_admin/teams_controller.rb
sportdb-admin-0.1.1 app/controllers/sport_db_admin/teams_controller.rb