Class: Renalware::Research::StudyParticipantsController
- Inherits:
-
BaseController
- Object
- ApplicationController
- ApplicationController
- BaseController
- Renalware::Research::StudyParticipantsController
- Includes:
- Concerns::Pageable
- Defined in:
- app/controllers/renalware/research/study_participants_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
-
#update ⇒ Object
Don’t update the participant id here (the patient) as that is immutable at this point.
Methods inherited from BaseController
Instance Method Details
#create ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/controllers/renalware/research/study_participants_controller.rb', line 22 def create participant = study.participants.build(participant_params) participant.joined_on ||= Time.zone.today participant if participant.save redirect_to( research_study_participants_path(study), notice: success_msg_for("participant") ) else render_new(participant) end end |
#destroy ⇒ Object
43 44 45 46 47 48 |
# File 'app/controllers/renalware/research/study_participants_controller.rb', line 43 def destroy participant = participant.destroy redirect_to research_study_participants_path(study), notice: "#{participant.patient} removed from the study" end |
#edit ⇒ Object
50 51 52 |
# File 'app/controllers/renalware/research/study_participants_controller.rb', line 50 def edit render_edit() end |
#index ⇒ Object
10 11 12 13 14 15 |
# File 'app/controllers/renalware/research/study_participants_controller.rb', line 10 def index StudyParticipant, :index? query = StudyParticipantsQuery.new(study: study, options: params[:q]) participants = query.call.page(page).per(per_page) render locals: { study: study, participants: participants, query: query.search } end |
#new ⇒ Object
37 38 39 40 41 |
# File 'app/controllers/renalware/research/study_participants_controller.rb', line 37 def new participant = study.participants.new(joined_on: Time.zone.today) participant render_new(participant) end |
#show ⇒ Object
17 18 19 20 |
# File 'app/controllers/renalware/research/study_participants_controller.rb', line 17 def show StudyParticipant, :show? redirect_to research_study_participants_path(study) end |
#update ⇒ Object
Don’t update the participant id here (the patient) as that is immutable at this point.
55 56 57 58 59 60 61 62 63 64 65 |
# File 'app/controllers/renalware/research/study_participants_controller.rb', line 55 def update participant = if participant.update(participant_params_for_update) redirect_to( research_study_participants_path(study), notice: success_msg_for("participant") ) else render_edit(participant) end end |