Class: Renalware::Virology::VaccinationTypesController

Inherits:
BaseController show all
Defined in:
app/controllers/renalware/virology/vaccination_types_controller.rb

Instance Method Summary collapse

Methods inherited from BaseController

#patient

Instance Method Details

#createObject



34
35
36
37
38
39
40
41
42
# File 'app/controllers/renalware/virology/vaccination_types_controller.rb', line 34

def create
  type = VaccinationType.new(type_params)
  authorize type
  if type.save
    redirect_to virology_vaccination_types_path
  else
    render :new, locals: { type: type }
  end
end

#destroyObject



44
45
46
47
# File 'app/controllers/renalware/virology/vaccination_types_controller.rb', line 44

def destroy
  find_and_authorise_type.destroy!
  redirect_to virology_vaccination_types_path
end

#editObject



14
15
16
17
# File 'app/controllers/renalware/virology/vaccination_types_controller.rb', line 14

def edit
  type = find_and_authorise_type
  render locals: { type: type }
end

#indexObject



8
9
10
11
12
# File 'app/controllers/renalware/virology/vaccination_types_controller.rb', line 8

def index
  types = VaccinationType.with_deleted.ordered
  authorize types
  render locals: { types: types }
end

#newObject



28
29
30
31
32
# File 'app/controllers/renalware/virology/vaccination_types_controller.rb', line 28

def new
  type = VaccinationType.new
  authorize type
  render locals: { type: type }
end

#sortObject



49
50
51
52
53
54
# File 'app/controllers/renalware/virology/vaccination_types_controller.rb', line 49

def sort
  authorize VaccinationType, :sort?
  ids = params[:virology_vaccination_type]
  VaccinationType.sort(ids)
  render json: ids
end

#updateObject



19
20
21
22
23
24
25
26
# File 'app/controllers/renalware/virology/vaccination_types_controller.rb', line 19

def update
  type = find_and_authorise_type
  if type.update(type_params)
    redirect_to virology_vaccination_types_path
  else
    render :edit, locals: { type: type }
  end
end