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
20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/controllers/renalware/research/study_participants_controller.rb', line 20 def create participant = study.participants.build(participant_params) participant.joined_on ||= Time.zone.today participant if participant.save render_current_action_with_locals else render_new(participant) end end |
#destroy ⇒ Object
38 39 40 41 42 43 |
# File 'app/controllers/renalware/research/study_participants_controller.rb', line 38 def destroy participant = participant.destroy redirect_to research_study_participants_path(study), notice: "#{participant.patient} removed from the study" end |
#edit ⇒ Object
45 46 47 |
# File 'app/controllers/renalware/research/study_participants_controller.rb', line 45 def edit render_edit() end |
#index ⇒ Object
10 11 12 13 |
# File 'app/controllers/renalware/research/study_participants_controller.rb', line 10 def index StudyParticipant, :index? render_current_action_with_locals end |
#new ⇒ Object
32 33 34 35 36 |
# File 'app/controllers/renalware/research/study_participants_controller.rb', line 32 def new participant = study.participants.new(joined_on: Time.zone.today) participant render_new(participant) end |
#show ⇒ Object
15 16 17 18 |
# File 'app/controllers/renalware/research/study_participants_controller.rb', line 15 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.
50 51 52 53 54 55 56 57 |
# File 'app/controllers/renalware/research/study_participants_controller.rb', line 50 def update participant = if participant.update(participant_params_for_update) render_current_action_with_locals else render_edit(participant) end end |