class Admin::RacesController

Public Instance Methods

create() click to toggle source
# File app/controllers/admin/races_controller.rb, line 12
def create
  respond_to do |format|
    format.html {
      if @race.save
        flash[:notice] = "Created #{@race.name}"
        redirect_to edit_admin_race_path(@race)
      else
        render :edit
      end
    }
    format.js {
      @race.category = Category.find_or_create_by_name("New Category")
      @race.save!
    }
  end
end
create_result() click to toggle source

Insert new Result

Params

  • before_result_id

Flash

  • notice

# File app/controllers/admin/races_controller.rb, line 79
def create_result
  @result = @race.create_result_before(params[:before_result_id])
  expire_cache
end
destroy() click to toggle source

Permanently destroy race and redirect to Event

Params

  • id

Flash

  • notice

# File app/controllers/admin/races_controller.rb, line 69
def destroy
  @race = Race.find(params[:id])
  @race.destroy
end
destroy_result() click to toggle source

Permanently destroy Result

Params

  • id

Flash

  • notice

# File app/controllers/admin/races_controller.rb, line 89
def destroy_result
  @result = Result.find(params[:result_id])
  @result.race.destroy_result @result
  @result.race.results true
end
edit() click to toggle source
# File app/controllers/admin/races_controller.rb, line 29
def edit
  @disciplines = [''] + Discipline.all.collect do |discipline|
    discipline.name
  end
  @disciplines.sort!
end
new() click to toggle source
# File app/controllers/admin/races_controller.rb, line 8
def new
  render :edit
end
propagate() click to toggle source

Create Races for all children to match parent Event

Params

  • event_id: parent Event ID

# File app/controllers/admin/races_controller.rb, line 98
def propagate
  @event.propagate_races
end
update() click to toggle source

Update existing Race

Params

  • id

  • event: Attributes Hash

Assigns

  • event: Unsaved Race

Flash

  • warn

# File app/controllers/admin/races_controller.rb, line 44
def update
  if @race.update_attributes(params[:race])
    expire_cache
    flash[:notice] = "Updated #{@race.name}"
    return redirect_to(edit_admin_race_path(@race))
  end
  render :edit
end
update_attribute() click to toggle source
# File app/controllers/admin/races_controller.rb, line 53
def update_attribute
  respond_to do |format|
    format.js {
      @race.send "#{params[:name]}=", params[:value]
      @race.save!
      expire_cache
      render :text => @race.send(params[:name]), :content_type => "text/html"
    }
  end
end