Class: Renalware::Research::StudiesController

Inherits:
BaseController show all
Includes:
Concerns::Pageable
Defined in:
app/controllers/renalware/research/studies_controller.rb

Instance Method Summary collapse

Methods inherited from BaseController

#patient

Instance Method Details

#createObject



22
23
24
25
26
27
28
29
30
# File 'app/controllers/renalware/research/studies_controller.rb', line 22

def create
  study = Study.new(study_params)
  authorize study
  if study.save_by(current_user)
    redirect_to research_studies_path, notice: success_msg_for("clinical study")
  else
    render_new(study)
  end
end

#destroyObject



46
47
48
49
50
# File 'app/controllers/renalware/research/studies_controller.rb', line 46

def destroy
  study = find_and_authorize_study
  study.destroy!
  redirect_to research_studies_path, notice: success_msg_for("clinical study")
end

#editObject



32
33
34
35
# File 'app/controllers/renalware/research/studies_controller.rb', line 32

def edit
  study = find_and_authorize_study
  render_edit(study)
end

#indexObject



10
11
12
13
14
# File 'app/controllers/renalware/research/studies_controller.rb', line 10

def index
  studies = Study.ordered.page(page).per(per_page)
  authorize studies
  render locals: { studies: studies }
end

#newObject



16
17
18
19
20
# File 'app/controllers/renalware/research/studies_controller.rb', line 16

def new
  study = Study.new
  authorize study
  render_new(study)
end

#updateObject



37
38
39
40
41
42
43
44
# File 'app/controllers/renalware/research/studies_controller.rb', line 37

def update
  study = find_and_authorize_study
  if study.update_by(current_user, study_params)
    redirect_to research_studies_path, notice: success_msg_for("clinical study")
  else
    render_edit(study)
  end
end