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



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

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



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

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

#editObject



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

def edit
  study = find_and_authorize_study
  render_edit(study)
end

#indexObject



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

def index
  query = Study.ordered.ransack(params[:q])
  studies = query.result.page(page).per(per_page)
  authorize studies
  render locals: { studies: studies, query: query }
end

#newObject



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

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

#updateObject



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

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