app/controllers/event_notes_controller.rb
# post
# for restricted or unrestricted notes
post
for restricted or unrestricted notes
post for restricted or unrestricted notes
def create
    safe_params = params.require(:event_note).permit(
      :student_id,
      :event_note_type_id,
      :text,
      :is_restricted,
      event_note_attachments_attributes: [:url]
    )
    authorized_or_raise! { Student.find(safe_params[:student_id]) }
    event_note = EventNote.new(safe_params.merge({
      is_restricted: safe_is_restricted_value_for_create(safe_params),
      educator_id: current_educator.id,
      recorded_at: Time.now
    }))
    if event_note.save
      serializer = EventNoteSerializer.dangerously_include_restricted_note_text(event_note)
      render json: serializer.serialize_event_note
    else
      render json: { errors: event_note.errors.full_messages }, status: 422
    end
  end
def create safe_params = params . require ( :event_note ) . permit ( :student_id , :event_note_type_id , :text , :is_restricted , event_note_attachments_attributes : [ :url ] ) authorized_or_raise! { Student . find ( safe_params [ :student_id ] ) } event_note = EventNote . new ( safe_params . merge ( { is_restricted : safe_is_restricted_value_for_create ( safe_params ) , educator_id : current_educator . id , recorded_at : Time . now } ) ) if event_note . save serializer = EventNoteSerializer . dangerously_include_restricted_note_text ( event_note ) render json : serializer . serialize_event_note else render json : { errors : event_note . errors . full_messages } , status : 422 end end
post
for restricted or unrestricted notes
post for restricted or unrestricted notes