Sha256: ac22b8db5c81bb2fd7b3600fa23df2f6048993d1e722a405c152465fa96e3745

Contents?: true

Size: 1.5 KB

Versions: 43

Compression:

Stored size: 1.5 KB

Contents

class Wco::ReportsController < Wco::ApplicationController

  before_action :set_lists

  def create
    params[:report][:tag_ids].delete ''

    @report = Wco::Report.new params[:report].permit!
    authorize! :create, @report
    if @report.save
      flash_notice "created report"
    else
      flash_alert "Cannot create report: #{@report.errors.messages}"
    end
    redirect_to action: 'index'
  end

  def destroy
    @report = Wco::Report.find params[:id]
    authorize! :destroy, @report
    if @report.destroy
      flash_notice 'ok'
    else
      flash_alert 'No luck.'
    end
    redirect_to action: 'index'
  end

  def edit
    @report = Wco::Report.unscoped.find params[:id]
    authorize! :edit, @report
  end

  def index
    authorize! :index, Wco::Report
    @reports = Wco::Report.all
    if params[:deleted]
      @reports = Wco::Report.unscoped.where( :deleted_at.ne => nil )
    end
  end

  def new
    authorize! :new, Wco::Report
    @new_report = Wco::Report.new
  end

  def show
    @report = Wco::Report.unscoped.find params[:id]
    authorize! :show, @report
  end

  def update
    params[:report][:tag_ids].delete ''

    @report = Wco::Report.unscoped.find params[:id]
    authorize! :update, @report
    if @report.update params[:report].permit!
      flash_notice "updated report"
    else
      flash_alert "Cannot update report: #{@report.errors.messages}"
    end
    redirect_to action: 'index'
  end

  ##
  ## private
  ##
  private

  def set_lists
    @tags_list = Wco::Tag.list
  end

end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
wco_models-3.1.0.81 app/controllers/wco/reports_controller.rb
wco_models-3.1.0.80 app/controllers/wco/reports_controller.rb
wco_models-3.1.0.79 app/controllers/wco/reports_controller.rb
wco_models-3.1.0.78 app/controllers/wco/reports_controller.rb
wco_models-3.1.0.77 app/controllers/wco/reports_controller.rb
wco_models-3.1.0.76 app/controllers/wco/reports_controller.rb
wco_models-3.1.0.75 app/controllers/wco/reports_controller.rb
wco_models-3.1.0.74 app/controllers/wco/reports_controller.rb
wco_models-3.1.0.73 app/controllers/wco/reports_controller.rb
wco_models-3.1.0.72 app/controllers/wco/reports_controller.rb
wco_models-3.1.0.71 app/controllers/wco/reports_controller.rb
wco_models-3.1.0.70 app/controllers/wco/reports_controller.rb
wco_models-3.1.0.69 app/controllers/wco/reports_controller.rb
wco_models-3.1.0.67 app/controllers/wco/reports_controller.rb
wco_models-3.1.0.66 app/controllers/wco/reports_controller.rb
wco_models-3.1.0.65 app/controllers/wco/reports_controller.rb
wco_models-3.1.0.64 app/controllers/wco/reports_controller.rb
wco_models-3.1.0.63 app/controllers/wco/reports_controller.rb
wco_models-3.1.0.62 app/controllers/wco/reports_controller.rb
wco_models-3.1.0.61 app/controllers/wco/reports_controller.rb