Class: Renalware::Problems::ProblemsController
- Inherits:
-
BaseController
- Object
- ApplicationController
- ApplicationController
- BaseController
- Renalware::Problems::ProblemsController
- Defined in:
- app/controllers/renalware/problems/problems_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #sort ⇒ Object
- #update ⇒ Object
Methods inherited from BaseController
Instance Method Details
#create ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 |
# File 'app/controllers/renalware/problems/problems_controller.rb', line 56 def create problem = patient.problems.new(problem_params) problem if problem.save redirect_to patient_problems_url(patient), notice: success_msg_for("problem") else flash.now[:error] = failed_msg_for("problem") render :new, locals: { patient: patient, problem: problem } end end |
#destroy ⇒ Object
68 69 70 71 72 73 74 75 |
# File 'app/controllers/renalware/problems/problems_controller.rb', line 68 def destroy problem = find_problem problem problem.by = current_user problem.save! problem.destroy redirect_to patient_problems_path(patient), notice: success_msg_for("problem") end |
#edit ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'app/controllers/renalware/problems/problems_controller.rb', line 27 def edit problem = find_problem problem render locals: { patient: patient, problem: problem } end |
#index ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'app/controllers/renalware/problems/problems_controller.rb', line 6 def index problems = patient.problems.with_notes problems render locals: { patient: patient, current_problems: problems.current.with_updated_by.ordered, archived_problems: problems.archived.with_created_by.ordered } end |
#new ⇒ Object
50 51 52 53 54 |
# File 'app/controllers/renalware/problems/problems_controller.rb', line 50 def new problem = patient.problems.build problem render locals: { patient: patient, problem: problem } end |
#show ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'app/controllers/renalware/problems/problems_controller.rb', line 16 def show problem = patient.problems.with_archived.with_versions.find(params[:id]) notes = problem.notes.with_updated_by.ordered problem render locals: { patient: patient, problem: problem, notes: notes } end |
#sort ⇒ Object
77 78 79 80 81 82 |
# File 'app/controllers/renalware/problems/problems_controller.rb', line 77 def sort Problem, :sort? ids = params[:problems_problem] Problem.sort(ids) render json: ids end |
#update ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/controllers/renalware/problems/problems_controller.rb', line 36 def update (problem = find_problem) if update_problem(problem) redirect_to patient_problem_path(patient, problem), notice: success_msg_for("problem") else flash.now[:error] = failed_msg_for("problem") render :edit, locals: { patient: patient, problem: problem } end end |