Module: Controller::UsedSeatsConcern

Included in:
Ecm::Courses::Backend::CoursesController
Defined in:
app/concerns/controller/used_seats_concern.rb

Instance Method Summary collapse

Instance Method Details

#decrement_used_seatsObject



13
14
15
16
17
18
19
20
21
# File 'app/concerns/controller/used_seats_concern.rb', line 13

def decrement_used_seats
  @resource = load_resource
  @resource.used_seats -= 1
  if @resource.save
    redirect_to collection_path, notice: I18n.t("controller.used_seats_concern.decrement.succeeded")
  else
    redirect_to collection_path, alert: I18n.t("controller.used_seats_concern.decrement.failed", errors: @resource.errors.full_messages.to_sentence)
  end
end

#increment_used_seatsObject



3
4
5
6
7
8
9
10
11
# File 'app/concerns/controller/used_seats_concern.rb', line 3

def increment_used_seats
  @resource = load_resource
  @resource.used_seats += 1
  if @resource.save
    redirect_to collection_path, notice: I18n.t("controller.used_seats_concern.increment.succeeded")
  else
    redirect_to collection_path, alert: I18n.t("controller.used_seats_concern.increment.failed", errors: @resource.errors.full_messages.to_sentence)
  end
end