Updated

app/controllers/admin / notes_controller.rb

A
34 lines of codes
5 methods
3.1 complexity/method
5 churn
15.46 complexity
0 duplications
class Admin::NotesController < Admin::AdminController
  1. Admin::NotesController assumes too much for instance variable '@note'
  2. Admin::NotesController assumes too much for instance variable '@petition'
  3. Admin::NotesController has no descriptive comment
before_action :fetch_petition before_action :fetch_note rescue_from ActiveRecord::RecordNotUnique do @note = @petition.note(true) and update end def show render 'admin/petitions/show' end def update if @note.update(note_params) redirect_to [:admin, @petition] else render 'admin/petitions/show' end end private def fetch_note @note = @petition.note || @petition.build_note end def fetch_petition @petition = Petition.find(params[:petition_id]) end def note_params params.require(:note).permit(:details) end end