Sha256: 368f4b3196d9281cc180da08fd4afd0e8734cbe6c1ba48558f6f6cbfee2fc70d

Contents?: true

Size: 1.24 KB

Versions: 10

Compression:

Stored size: 1.24 KB

Contents

class Dorsale::CustomerVault::OriginsController < ::Dorsale::CustomerVault::ApplicationController
  before_action :set_objects, only: [:edit, :update]

  def index
    authorize model, :list?

    @origins ||= scope.all
  end

  def new
    @origin ||= scope.new

    authorize @origin, :create?
  end

  def create
    @origin ||= scope.new(origin_params_for_create)

    authorize @origin, :create?

    if @origin.save
      flash[:notice] = t("messages.origins.create_ok")
      redirect_to back_url
    else
      render action: :new
    end
  end

  def edit
    authorize @origin, :update?
  end

  def update
    authorize @origin, :update?

    if @origin.update(origin_params_for_update)
      flash[:notice] = t("messages.origins.update_ok")
      redirect_to back_url
    else
      render action: :edit
    end
  end

  private

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

  def model
    ::Dorsale::CustomerVault::Origin
  end

  def back_url
    customer_vault_origins_path
  end

  def permitted_params
    [
      :name,
    ]
  end

  def origin_params
    params.fetch(:origin, {}).permit(permitted_params)
  end

  def origin_params_for_create
    origin_params
  end

  def origin_params_for_update
    origin_params
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
dorsale-3.8.1 app/controllers/dorsale/customer_vault/origins_controller.rb
dorsale-3.8.0 app/controllers/dorsale/customer_vault/origins_controller.rb
dorsale-3.7.8 app/controllers/dorsale/customer_vault/origins_controller.rb
dorsale-3.7.7 app/controllers/dorsale/customer_vault/origins_controller.rb
dorsale-3.7.6 app/controllers/dorsale/customer_vault/origins_controller.rb
dorsale-3.7.5 app/controllers/dorsale/customer_vault/origins_controller.rb
dorsale-3.7.4 app/controllers/dorsale/customer_vault/origins_controller.rb
dorsale-3.7.2 app/controllers/dorsale/customer_vault/origins_controller.rb
dorsale-3.7.1 app/controllers/dorsale/customer_vault/origins_controller.rb
dorsale-3.7.0 app/controllers/dorsale/customer_vault/origins_controller.rb