Class: FReCon::ParticipationsController

Inherits:
Controller show all
Defined in:
lib/frecon/controllers/participations_controller.rb

Class Method Summary collapse

Methods inherited from Controller

could_not_find, delete, index, model, model_name, process_request, show, show_attribute, team_number_to_team_id, update

Class Method Details

.competition(params) ⇒ Object



29
30
31
# File 'lib/frecon/controllers/participations_controller.rb', line 29

def self.competition(params)
  show_attribute params, :competition
end

.create(request, params) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/frecon/controllers/participations_controller.rb', line 12

def self.create(request, params)
  post_data = process_request request
  return post_data if post_data.is_an?(Array)
  
  # Convert team number to team_id.
  post_data = team_number_to_team_id(post_data)

  @model = model.new
  @model.attributes = post_data

  if @model.save
    [201, @model.to_json]
  else
    [422, ErrorFormatter.format(@model.errors.full_messages)]
  end
end

.team(params) ⇒ Object



33
34
35
# File 'lib/frecon/controllers/participations_controller.rb', line 33

def self.team(params)
  show_attribute params, :team
end