Class: MrCommon::Registrations::RegistrationsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/mr_common/registrations/registrations_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



18
19
20
21
22
23
24
25
26
27
# File 'app/controllers/mr_common/registrations/registrations_controller.rb', line 18

def create
  @registration = Registration.new(registration_params)

  if @registration.save
    redirect_to registrations_path, notice: "Registration saved."
  else
    flash.now[:alert] = MrCommon.registration_failure_alert
    render :new, status: :unprocessable_entity
  end
end

#destroyObject



44
45
46
47
48
49
50
51
52
# File 'app/controllers/mr_common/registrations/registrations_controller.rb', line 44

def destroy
  @registration = Registration.find(params[:id])

  if @registration.destroy
    redirect_to registrations_path, notice: "Registration destroyed."
  else
    redirect_to @registration, alert: "Unable to destroy Registration."
  end
end

#editObject



29
30
31
# File 'app/controllers/mr_common/registrations/registrations_controller.rb', line 29

def edit
  @registration = Registration.find(params[:id])
end

#indexObject



6
7
8
# File 'app/controllers/mr_common/registrations/registrations_controller.rb', line 6

def index
  @registrations = Registration.order(first_name: :asc, last_name: :asc)
end

#newObject



14
15
16
# File 'app/controllers/mr_common/registrations/registrations_controller.rb', line 14

def new
  @registration = Registration.new
end

#showObject



10
11
12
# File 'app/controllers/mr_common/registrations/registrations_controller.rb', line 10

def show
  @registration = Registration.find(params[:id])
end

#updateObject



33
34
35
36
37
38
39
40
41
42
# File 'app/controllers/mr_common/registrations/registrations_controller.rb', line 33

def update
  @registration = Registration.find(params[:id])

  if @registration.update(registration_params)
    redirect_to @registration, notice: "Registration saved."
  else
    flash.now[:alert] = MrCommon.registration_failure_alert
    render :new, status: :unprocessable_entity
  end
end