Class: SportDbAdmin::TeamsController
- Inherits:
-
SportDbAdminController
- Object
- ActionController::Base
- SportDbAdminController
- SportDbAdmin::TeamsController
- Defined in:
- app/controllers/sport_db_admin/teams_controller.rb
Instance Method Summary collapse
-
#index ⇒ Object
GET /teams.
- #index_clubs ⇒ Object
- #index_national_teams ⇒ Object
-
#shortcut ⇒ Object
GET /:key e.g /barcelona or /rapid etc.
-
#show ⇒ Object
GET /teams/1.
Instance Method Details
#index ⇒ Object
GET /teams
8 9 10 11 |
# File 'app/controllers/sport_db_admin/teams_controller.rb', line 8 def index # make clubs default view index_clubs end |
#index_clubs ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/controllers/sport_db_admin/teams_controller.rb', line 18 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 |
#index_national_teams ⇒ Object
13 14 15 16 |
# File 'app/controllers/sport_db_admin/teams_controller.rb', line 13 def index_national_teams # todo: join country table to order by country.key ?? @teams = Team.where( club: false ).order( 'country_id' ).all end |
#shortcut ⇒ Object
GET /:key e.g /barcelona or /rapid etc.
37 38 39 40 |
# File 'app/controllers/sport_db_admin/teams_controller.rb', line 37 def shortcut @team = Team.find_by_key!( params[:key] ) render :show end |
#show ⇒ Object
GET /teams/1
43 44 45 |
# File 'app/controllers/sport_db_admin/teams_controller.rb', line 43 def show @team = Team.find(params[:id]) end |