Class: Elabs::ReportsController

Inherits:
ElabsPublicController show all
Defined in:
app/controllers/elabs/reports_controller.rb

Constant Summary

Constants inherited from ElabsPublicController

ElabsPublicController::ALLOWED_NESTED_FROM, ElabsPublicController::ALLOWED_ORDER_FROM, ElabsPublicController::DEFAULT_ORDER, ElabsPublicController::IS_NSFW_FILTERABLE, ElabsPublicController::MAX_ITEMS_PER_PAGE

Instance Method Summary collapse

Instance Method Details

#createObject

POST /reports POST /reports.json rubocop:disable Metrics/AbcSize



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/controllers/elabs/reports_controller.rb', line 6

def create
  return if trap_dumb_bot_in 'body', _('Report was successfully created. Thank you Bishop.')

  report = complete_report_with_user

  respond_to do |format|
    if report.save
      format.html { redirect_to request.referer, notice: _('Report was successfully created.') }
      format.json { render json: { message: 'ok' }, status: :created }
    else
      format.html { redirect_to request.referer, notice: { error: report.errors } }
      format.json { render json: report.errors, status: :unprocessable_entity }
    end
  end
end