Class: Ideasbugs::SubmissionsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/ideasbugs/submissions_controller.rb

Overview

The widget's write endpoint: POST /feedbacks.

Public, so it stays on ApplicationController and never inherits a host's admin base controller — someone filing a bug report must not be asked for a staff session. The triage actions live in FeedbacksController, which does inherit it.

Instance Method Summary collapse

Instance Method Details

#createObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/controllers/ideasbugs/submissions_controller.rb', line 24

def create
  feedback = Feedback.new(feedback_params)
  feedback.user_agent = request.user_agent
  feedback.tenant = current_tenant
  attribute_author(feedback)

  error = attach_screenshots(feedback)
  return render json: { errors: [error] }, status: :unprocessable_entity if error

  if feedback.save
    notify_host(feedback)
    head :created
  else
    render json: { errors: feedback.errors.full_messages }, status: :unprocessable_entity
  end
end