Sha256: b5d71fa61dfec792fab680eef7becc43c6a53a081d0a3ffe63625955eed0fabc

Contents?: true

Size: 1.25 KB

Versions: 40

Compression:

Stored size: 1.25 KB

Contents

module Virgo
  class Admin::ColumnsController < Admin::BaseController
    before_action :set_column, only: [:show, :edit, :update, :destroy]

    handles_sortable_columns

    def index
      if params[:sort].nil?
        flash.keep
        redirect_to admin_columns_path(sort: 'weight') and return
      end

      @columns = Column.order(sort_order).with_post_count.page(params[:page])
    end

    def new
      @column = Column.new
    end

    def create
      @column = Column.new(column_params)

      authorize! :create, @column

      if @column.save
        flash[:notice] = "Column created"
        redirect_to admin_columns_path
      else
        render :new
      end
    end

    def edit
    end

    def update
      if @column.update(column_params)
        flash[:notice] = "Column settings updated"
        redirect_to admin_columns_path
      else
        render :edit
      end
    end

    def destroy
      @column.destroy

      flash[:notice] = "Column removed"

      redirect_to admin_columns_path
    end

    private

    def set_column
      @column = Column.friendly.find(params[:id])

      authorize! :manage, @column
    end

    def column_params
      params.permit(column: [:name, :description, :weight, :image, :slug])[:column]
    end
  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
virgo-0.3.17 app/controllers/virgo/admin/columns_controller.rb
virgo-0.3.16 app/controllers/virgo/admin/columns_controller.rb
virgo-0.3.15 app/controllers/virgo/admin/columns_controller.rb
virgo-0.3.14 app/controllers/virgo/admin/columns_controller.rb
virgo-0.3.13 app/controllers/virgo/admin/columns_controller.rb
virgo-0.3.12 app/controllers/virgo/admin/columns_controller.rb
virgo-0.3.11 app/controllers/virgo/admin/columns_controller.rb
virgo-0.3.10 app/controllers/virgo/admin/columns_controller.rb
virgo-0.3.9 app/controllers/virgo/admin/columns_controller.rb
virgo-0.3.8 app/controllers/virgo/admin/columns_controller.rb
virgo-0.3.7 app/controllers/virgo/admin/columns_controller.rb
virgo-0.3.6 app/controllers/virgo/admin/columns_controller.rb
virgo-0.3.4 app/controllers/virgo/admin/columns_controller.rb
virgo-0.3.3 app/controllers/virgo/admin/columns_controller.rb
virgo-0.3.2 app/controllers/virgo/admin/columns_controller.rb
virgo-0.3.1 app/controllers/virgo/admin/columns_controller.rb
virgo-0.3 app/controllers/virgo/admin/columns_controller.rb
virgo-0.2.9 app/controllers/virgo/admin/columns_controller.rb
virgo-0.2.8 app/controllers/virgo/admin/columns_controller.rb
virgo-0.2.7 app/controllers/virgo/admin/columns_controller.rb