Sha256: 3b7b9ab83d5cba3d531a88fe54deab3e89d2711792ab7c116fe6f759577fa816

Contents?: true

Size: 1014 Bytes

Versions: 2

Compression:

Stored size: 1014 Bytes

Contents

require_dependency 'comable/admin/application_controller'

module Comable
  module Admin
    class CustomersController < Comable::Admin::ApplicationController
      include Comable::PermittedAttributes

      load_and_authorize_resource class: Comable::Customer.name, except: :index

      def index
        @q = Comable::Customer.ransack(params[:q])
        @customers = @q.result.page(params[:page]).accessible_by(current_ability)
      end

      def show
      end

      def edit
      end

      def update
        if @customer.update_attributes(customer_params)
          redirect_to comable.admin_customer_path(@customer), notice: Comable.t('successful')
        else
          flash.now[:alert] = Comable.t('failure')
          render :edit
        end
      end

      private

      def customer_params
        params.require(:customer).permit(
          :email,
          :password,
          :role,
          bill_address_attributes: permitted_address_attributes
        )
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
comable_backend-0.3.4 app/controllers/comable/admin/customers_controller.rb
comable_backend-0.3.3 app/controllers/comable/admin/customers_controller.rb