Sha256: 71ae251b3fcaf4f062d9ade31af318757ae8591014ce5de0a1212d546a36a84f

Contents?: true

Size: 1.34 KB

Versions: 5

Compression:

Stored size: 1.34 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 new
      end

      def create
        if @shipment_method.save
          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 edit
      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(
          :activated_flag,
          :name,
          :fee,
          :traking_url
        )
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
comable-backend-0.7.0.beta1 app/controllers/comable/admin/shipment_methods_controller.rb
comable-backend-0.6.0 app/controllers/comable/admin/shipment_methods_controller.rb
comable_backend-0.5.0 app/controllers/comable/admin/shipment_methods_controller.rb
comable_backend-0.4.2 app/controllers/comable/admin/shipment_methods_controller.rb
comable_backend-0.4.1 app/controllers/comable/admin/shipment_methods_controller.rb