Sha256: b7acbf8d433669c231575ea97fd7c22ff709b14a6e40d852ce431a87bab2173b

Contents?: true

Size: 1.3 KB

Versions: 5

Compression:

Stored size: 1.3 KB

Contents

require_dependency "easy_reports/application_controller"

module EasyReports
  class ReportsController < ApplicationController
    before_action :set_report, only: [:show, :edit, :update, :destroy]

    # GET /reports
    def index
      @reports = Report.all
    end

    # GET /reports/1
    def show
    end

    # GET /reports/new
    def new
      @report = Report.new
    end

    # GET /reports/1/edit
    def edit
    end

    # POST /reports
    def create
      @report = Report.new(report_params)

      if @report.save
        redirect_to @report, notice: 'Report was successfully created.'
      else
        render :new
      end
    end

    # PATCH/PUT /reports/1
    def update
      if @report.update(report_params)
        redirect_to @report, notice: 'Report was successfully updated.'
      else
        render :edit
      end
    end

    # DELETE /reports/1
    def destroy
      @report.destroy
      redirect_to reports_url, notice: 'Report was successfully destroyed.'
    end

    private
      # Use callbacks to share common setup or constraints between actions.
      def set_report
        @report = Report.find(params[:id])
      end

      # Only allow a trusted parameter "white list" through.
      def report_params
        params.require(:report).permit(:title, :description)
      end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
easy_reports-0.0.10 app/controllers/easy_reports/reports_controller.rb
easy_reports-0.0.9 app/controllers/easy_reports/reports_controller.rb
easy_reports-0.0.8 app/controllers/easy_reports/reports_controller.rb
easy_reports-0.0.7 app/controllers/easy_reports/reports_controller.rb
easy_reports-0.0.6 app/controllers/easy_reports/reports_controller.rb