15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/raport/concerns/controllers/reportify.rb', line 15
def create_report
if Raport.config.formats.include?(request.format.to_sym)
@report = current_report_owner.reports.create(report_attributes)
respond_to do |format|
format.any do
if request.xhr?
json = @report.errors.empty? ? @report.as_json(methods: :permalink) : { errors: @report.errors }.to_json
render json: json
else
redirect_to polymorphic_path([current_namespace, @report])
end
end
end
end
end
|