14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'app/controllers/trackguard/admin/visitors_controller.rb', line 14
def flag
if @visitor.update(
flagged_at: Time.current,
flag_reason: params[:flag_reason].presence,
flagged_by: params[:flagged_by].presence || Visitor::FLAGGED_BY.first
)
respond_to do |format|
format.html { redirect_back_or_to dashboard_path }
format.json { render json: { status: "ok", ip: @visitor.ip, flagged_at: @visitor.flagged_at } }
end
else
respond_to do |format|
format.html { redirect_back_or_to dashboard_path, alert: @visitor.errors.full_messages.join(", ") }
format.json { render json: { errors: @visitor.errors.full_messages }, status: :unprocessable_entity }
end
end
end
|