class Admin::NotesController < Admin::AdminController - Admin::NotesController assumes too much for instance variable '@note'
- Admin::NotesController assumes too much for instance variable '@petition'
- 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