Sha256: 694e995b9389c85279c774002f68632d7013351c38c4d043bfc73537ebf5f428

Contents?: true

Size: 1.35 KB

Versions: 3

Compression:

Stored size: 1.35 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]).by_newest
      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

3 entries across 3 versions & 1 rubygems

Version Path
comable-backend-0.7.1 app/controllers/comable/admin/shipment_methods_controller.rb
comable-backend-0.7.0 app/controllers/comable/admin/shipment_methods_controller.rb
comable-backend-0.7.0.beta2 app/controllers/comable/admin/shipment_methods_controller.rb