Class: CodesController

Inherits:
AdminController show all
Defined in:
app/controllers/codes_controller.rb

Overview

Managing user codes

Instance Method Summary collapse

Instance Method Details

#createObject

post /codes



13
14
15
16
17
18
19
20
# File 'app/controllers/codes_controller.rb', line 13

def create
  @entity = Code.new(creation_parameters)
  if @entity.save
    form_processed_ok(admin_code_path(id: @entity.id))
  else
    form_processed_with_error(:new)
  end
end

#destroyObject

delete /codes/:id



37
38
39
40
41
# File 'app/controllers/codes_controller.rb', line 37

def destroy
  flash[:notice] = t('codes.destroy.success') if @entity.destroy

  redirect_to admin_codes_path
end

#editObject

get /codes/:id/edit



23
24
# File 'app/controllers/codes_controller.rb', line 23

def edit
end

#newObject

get /codes/new



8
9
10
# File 'app/controllers/codes_controller.rb', line 8

def new
  @entity = Code.new
end

#updateObject

patch /codes/:id



27
28
29
30
31
32
33
34
# File 'app/controllers/codes_controller.rb', line 27

def update
  if @entity.update(entity_parameters)
    flash[:notice] = t('codes.update.success')
    form_processed_ok(admin_code_path(id: @entity.id))
  else
    form_processed_with_error(:edit)
  end
end