1 class ReportsController < ApplicationController
4 before_action :authorize_web
5 before_action :require_user
8 if required_new_report_params_present?
10 @report.issue = Issue.find_or_initialize_by(create_new_report_params)
12 redirect_to root_path, :notice => t(".missing_params")
17 @report = current_user.reports.new(report_params)
18 @report.issue = Issue.find_or_initialize_by(:reportable_id => params[:report][:issue][:reportable_id], :reportable_type => params[:report][:issue][:reportable_type])
22 @report.issue.reopen! unless @report.issue.open?
23 redirect_to helpers.reportable_url(@report.issue.reportable), :notice => t(".successful_report")
25 redirect_to new_report_path(:reportable_type => @report.issue.reportable_type, :reportable_id => @report.issue.reportable_id), :notice => t(".provide_details")
31 def required_new_report_params_present?
32 create_new_report_params["reportable_id"].present? && create_new_report_params["reportable_type"].present?
35 def create_new_report_params
36 params.permit(:reportable_id, :reportable_type)
40 params[:report].permit(:details, :category)