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



28
29
30
31
32
33
34
35
36
# File 'app/controllers/renalware/research/studies_controller.rb', line 28

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



52
53
54
55
56
# File 'app/controllers/renalware/research/studies_controller.rb', line 52

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

#editObject



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

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



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

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

#showObject



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

def show
  study = find_and_authorize_study
  render locals: { study: study }
end

#updateObject



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

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