Sha256: b0b43066b9e4febdbc95b26ff60bc037bf96e52aaf7c0cbe2258494fe6620719

Contents?: true

Size: 1.55 KB

Versions: 27

Compression:

Stored size: 1.55 KB

Contents

module Dorsale
  module ExpenseGun
    class ExpenseLinesController < ::Dorsale::ExpenseGun::ApplicationController
      before_action :set_objects

      def index
        redirect_to dorsale.expense_gun_expense_path(@expense)
      end

      def new
        authorize! :edit, @expense

        @expense_line = @expense.expense_lines.new
      end

      def create
        authorize! :edit, @expense

        @expense_line = @expense.expense_lines.new(expense_line_params)

        if @expense_line.save
          flash[:success] = t("expense_gun.expense_line.flash.created")
          redirect_to dorsale.expense_gun_expense_path(@expense)
        else
          render :new
        end
      end

      def edit
        authorize! :edit, @expense
      end

      def update
        authorize! :edit, @expense
        if @expense_line.update_attributes(expense_line_params)
          flash[:success] = t("expense_gun.expense_line.flash.created")
          redirect_to dorsale.expense_gun_expense_path(@expense)
        else
          render :edit
        end
      end

      def destroy
        authorize! :edit, @expense

        @expense_line.destroy
        flash[:success] = t("expense_gun.expense_line.flash.created")
        redirect_to dorsale.expense_gun_expense_path(@expense)
      end

      private

      def set_objects
        @expense      = Expense.find params[:expense_id]
        @expense_line = ExpenseLine.find params[:id] if params[:id].present?
      end

      def expense_line_params
        params.require(:expense_line).permit!
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
dorsale-3.0.2 app/controllers/dorsale/expense_gun/expense_lines_controller.rb
dorsale-3.0.1 app/controllers/dorsale/expense_gun/expense_lines_controller.rb
dorsale-3.0.0 app/controllers/dorsale/expense_gun/expense_lines_controller.rb
dorsale-2.7.3 app/controllers/dorsale/expense_gun/expense_lines_controller.rb
dorsale-2.7.2 app/controllers/dorsale/expense_gun/expense_lines_controller.rb
dorsale-2.7.1 app/controllers/dorsale/expense_gun/expense_lines_controller.rb
dorsale-2.7.0 app/controllers/dorsale/expense_gun/expense_lines_controller.rb
dorsale-2.6.8 app/controllers/dorsale/expense_gun/expense_lines_controller.rb
dorsale-2.6.7 app/controllers/dorsale/expense_gun/expense_lines_controller.rb
dorsale-2.6.6 app/controllers/dorsale/expense_gun/expense_lines_controller.rb
dorsale-2.6.5 app/controllers/dorsale/expense_gun/expense_lines_controller.rb
dorsale-2.6.4 app/controllers/dorsale/expense_gun/expense_lines_controller.rb
dorsale-2.6.3 app/controllers/dorsale/expense_gun/expense_lines_controller.rb
dorsale-2.6.2 app/controllers/dorsale/expense_gun/expense_lines_controller.rb
dorsale-2.6.1 app/controllers/dorsale/expense_gun/expense_lines_controller.rb
dorsale-2.6.0 app/controllers/dorsale/expense_gun/expense_lines_controller.rb
dorsale-2.5.0 app/controllers/dorsale/expense_gun/expense_lines_controller.rb
dorsale-2.4.3 app/controllers/dorsale/expense_gun/expense_lines_controller.rb
dorsale-2.4.2 app/controllers/dorsale/expense_gun/expense_lines_controller.rb
dorsale-2.4.1 app/controllers/dorsale/expense_gun/expense_lines_controller.rb