Sha256: 27c558cda1b97c21faf8472f20b8f7ad155903b72c6f7255ae9427cd68816b6e

Contents?: true

Size: 1.07 KB

Versions: 6

Compression:

Stored size: 1.07 KB

Contents

module Admin

  class LookupsController < BaseController

    def index
      @category = params[:category]
      @lookups = Lookup.where(category: @category).order(:code, :created_at)
      if @lookups.blank? && @category.present?
        redirect_to admin_lookups_index_path
        return
      end
    end

    def new
      @lookup = Lookup.new
    end

    def create
      @lookup = Lookup.new(params[:lookup])
      if @lookup.save
        redirect_to admin_lookups_index_path(category: @lookup.category)
      else
        render :new
      end
    end

    def show
      @lookup = Lookup.find(params[:id])
    end

    def edit
      @lookup = Lookup.find(params[:id])
    end

    def update
      @lookup = Lookup.find(params[:id])
      if @lookup.update_attributes(params[:lookup].permit!)
        redirect_to admin_lookups_index_path(category: @lookup.category)
      else
        render :edit
      end
    end

    def destroy
      @lookup = Lookup.find(params[:id])
      @lookup.destroy
      redirect_to admin_lookups_index_path(category: @lookup.category)
    end

  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
coalla-cms-0.7.0.0 app/controllers/admin/lookups_controller.rb
coalla-cms-0.5.2.4 app/controllers/admin/lookups_controller.rb
coalla-cms-0.6.1.1 app/controllers/admin/lookups_controller.rb
coalla-cms-0.6.0.9 app/controllers/admin/lookups_controller.rb
coalla-cms-0.5.1.9 app/controllers/admin/lookups_controller.rb
coalla-cms-0.5.1.8 app/controllers/admin/lookups_controller.rb