Sha256: 70097633385136790f241494c9852273ed778562030c512c7adbc757b0941da9

Contents?: true

Size: 1.2 KB

Versions: 16

Compression:

Stored size: 1.2 KB

Contents

module Gaku
  class Admin::TemplatesController < Admin::BaseController

    responders :collection

    respond_to :js,   only: %i( new create edit update destroy index )
    respond_to :html, only: :download

    before_action :set_template, only: %i( download edit update destroy )

    def new
      @template = Template.new
    end

    def create
      @template = Template.new(template_params)
      if @template.save
        set_count
        respond_with @template
      else
        render :new
      end
    end

    def edit
      respond_with @template
    end

    def update
      @template.update(template_params)
      respond_with @template
    end

    def download
      send_file @template.file.path
    end

    def index
      @templates = Template.all
      set_count
      respond_with @templates
    end

    def destroy
      @template.destroy
      set_count
      respond_with @template
    end

    private

    def set_count
      @count = Template.count
    end

    def set_template
      @template = Template.find(params[:id])
    end

    def template_params
      params.require(:template).permit(attributes)
    end

    def attributes
      %i( name context locked file )
    end

  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
gaku_admin-0.3.0 app/controllers/gaku/admin/templates_controller.rb
gaku_admin-0.3.0.pre.4 app/controllers/gaku/admin/templates_controller.rb
gaku_admin-0.3.0.pre.3 app/controllers/gaku/admin/templates_controller.rb
gaku_admin-0.3.0.pre.2 app/controllers/gaku/admin/templates_controller.rb
gaku_admin-0.3.0.pre.1 app/controllers/gaku/admin/templates_controller.rb
gaku_admin-0.3.0.pre.0 app/controllers/gaku/admin/templates_controller.rb
gaku-0.2.4 admin/app/controllers/gaku/admin/templates_controller.rb
gaku_admin-0.2.4 app/controllers/gaku/admin/templates_controller.rb
gaku-0.2.3 admin/app/controllers/gaku/admin/templates_controller.rb
gaku_admin-0.2.3 app/controllers/gaku/admin/templates_controller.rb
gaku-0.2.2 admin/app/controllers/gaku/admin/templates_controller.rb
gaku_admin-0.2.2 app/controllers/gaku/admin/templates_controller.rb
gaku-0.2.1 admin/app/controllers/gaku/admin/templates_controller.rb
gaku_admin-0.2.1 app/controllers/gaku/admin/templates_controller.rb
gaku-0.2.0 admin/app/controllers/gaku/admin/templates_controller.rb
gaku_admin-0.2.0 app/controllers/gaku/admin/templates_controller.rb