Sha256: 47cf7ad1b83a7ff7ef032855363cd66eaa5634accb6180b53454bbc9cf970a63

Contents?: true

Size: 1.37 KB

Versions: 18

Compression:

Stored size: 1.37 KB

Contents

class Dorsale::BillingMachine::PaymentTermsController < ::Dorsale::BillingMachine::ApplicationController
  before_action :set_objects, only: [:edit, :update]

  def index
    authorize model, :list?

    @payment_terms ||= scope.all
  end

  def new
    @payment_term ||= scope.new

    authorize @payment_term, :create?
  end

  def create
    @payment_term ||= scope.new(payment_term_params_for_create)

    authorize @payment_term, :create?
    if @payment_term.save

      flash[:notice] = t("payment_terms.create_ok")
      redirect_to back_url
    else
      render action: :new
    end
  end

  def edit
    authorize @payment_term, :update?
  end

  def update
    authorize @payment_term, :update?

    if @payment_term.update(payment_term_params_for_update)
      flash[:notice] = t("payment_terms.update_ok")
      redirect_to back_url
    else
      render action: :edit
    end
  end

  private

  def set_objects
    @payment_term ||= scope.find(params[:id])
  end

  def model
    ::Dorsale::BillingMachine::PaymentTerm
  end

  def back_url
    url_for(action: :index, id: nil)
  end

  def permitted_params
    [
      :label,
    ]
  end

  def payment_term_params
    params.fetch(:billing_machine_payment_term, {}).permit(permitted_params)
  end

  def payment_term_params_for_create
    payment_term_params
  end

  def payment_term_params_for_update
    payment_term_params
  end

end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
dorsale-3.8.1 app/controllers/dorsale/billing_machine/payment_terms_controller.rb
dorsale-3.8.0 app/controllers/dorsale/billing_machine/payment_terms_controller.rb
dorsale-3.7.8 app/controllers/dorsale/billing_machine/payment_terms_controller.rb
dorsale-3.7.7 app/controllers/dorsale/billing_machine/payment_terms_controller.rb
dorsale-3.7.6 app/controllers/dorsale/billing_machine/payment_terms_controller.rb
dorsale-3.7.5 app/controllers/dorsale/billing_machine/payment_terms_controller.rb
dorsale-3.7.4 app/controllers/dorsale/billing_machine/payment_terms_controller.rb
dorsale-3.7.2 app/controllers/dorsale/billing_machine/payment_terms_controller.rb
dorsale-3.7.1 app/controllers/dorsale/billing_machine/payment_terms_controller.rb
dorsale-3.7.0 app/controllers/dorsale/billing_machine/payment_terms_controller.rb
dorsale-3.6.1 app/controllers/dorsale/billing_machine/payment_terms_controller.rb
dorsale-3.6.0 app/controllers/dorsale/billing_machine/payment_terms_controller.rb
dorsale-3.5.2 app/controllers/dorsale/billing_machine/payment_terms_controller.rb
dorsale-3.5.1 app/controllers/dorsale/billing_machine/payment_terms_controller.rb
dorsale-3.5.0 app/controllers/dorsale/billing_machine/payment_terms_controller.rb
dorsale-3.4.0 app/controllers/dorsale/billing_machine/payment_terms_controller.rb
dorsale-3.3.0 app/controllers/dorsale/billing_machine/payment_terms_controller.rb
dorsale-3.2.0 app/controllers/dorsale/billing_machine/payment_terms_controller.rb