Sha256: eb563094b353cab236becb8617ca2a6648cb7a52b2b1a84e0bbf8f5daf4ad8b3

Contents?: true

Size: 1.29 KB

Versions: 1

Compression:

Stored size: 1.29 KB

Contents

require_dependency 'comable/admin/application_controller'

module Comable
  module Admin
    class StoreController < ApplicationController
      # GET /admin/store
      def show
        @store = Comable::Store.first
        return redirect_to action: :new unless @store
      end

      # GET /admin/store/new
      def new
        @store = Comable::Store.new
      end

      # GET /admin/store/edit
      def edit
        @store = Comable::Store.first
      end

      # POST /admin/store
      def create
        @store = Comable::Store.new(store_params)

        if @store.save
          redirect_to comable.admin_store_url(@store), notice: 'Store was successfully created.'
        else
          render :new
        end
      end

      # PATCH/PUT /admin/store
      def update
        @store = Comable::Store.first
        if @store.update(store_params)
          redirect_to comable.admin_store_url(@store), notice: 'Store was successfully updated.'
        else
          render :edit
        end
      end

      private

      # Only allow a trusted parameter "white list" through.
      def store_params
        params.require(:store).permit(
          :name,
          :meta_keyword,
          :meta_description,
          :email_sender,
          :email_activate_flag
        )
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
comable_backend-0.2.0 app/controllers/comable/admin/store_controller.rb