1 class ReportsController < ApplicationController
4 before_action :authorize_web
5 before_action :require_user
8 if create_new_report_params.present?
10 @report.issue = Issue.find_or_initialize_by(create_new_report_params)
15 @report = current_user.reports.new(report_params)
16 @report.issue = Issue.find_or_initialize_by(:reportable_id => params[:report][:issue][:reportable_id], :reportable_type => params[:report][:issue][:reportable_type])
20 # FIXME: reopen issue if necessary
21 redirect_to root_path, :notice => t("issues.create.successful_report")
23 redirect_to new_report_path(:reportable_type => @report.issue.reportable_type, :reportable_id => @report.issue.reportable_id), :notice => t("issues.create.provide_details")
29 def create_new_report_params
30 params.permit(:reportable_id, :reportable_type)
34 params[:report].permit(:details, :category)