Sha256: a4fb7984f01c03b2020baf53f50f41df89f51b7b13f9a5817e48cd4c8a27f6f6

Contents?: true

Size: 1.32 KB

Versions: 3

Compression:

Stored size: 1.32 KB

Contents

require_dependency 'comable/admin/application_controller'

module Comable
  module Admin
    class ShipmentMethodsController < Comable::Admin::ApplicationController
      load_and_authorize_resource class: Comable::ShipmentMethod.name

      def index
        @shipment_methods = @shipment_methods.page(params[:page])
      end

      def show
        render :edit
      end

      def create
        if @shipment_method.update_attributes(shipment_method_params)
          redirect_to comable.admin_shipment_method_path(@shipment_method), notice: Comable.t('successful')
        else
          flash.now[:alert] = Comable.t('failure')
          render :new
        end
      end

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

      def destroy
        @shipment_method.destroy
        redirect_to comable.admin_shipment_methods_path, notice: Comable.t('successful')
      end

      private

      def shipment_method_params
        params.require(:shipment_method).permit(
          :activate_flag,
          :name,
          :fee,
          :traking_url
        )
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
comable_backend-0.3.2 app/controllers/comable/admin/shipment_methods_controller.rb
comable_backend-0.3.1 app/controllers/comable/admin/shipment_methods_controller.rb
comable_backend-0.3.0 app/controllers/comable/admin/shipment_methods_controller.rb