Sha256: 3d62b3bd721dd5213e6aaacb474664bb5d7a9ed4848914a3bf2b76691e7e3a91

Contents?: true

Size: 1.23 KB

Versions: 1

Compression:

Stored size: 1.23 KB

Contents

require_dependency 'cavy/application_controller'

module Cavy
  class AdminPageTemplatesController < ApplicationController
    layout 'cavy/admin_layout'

    def index
      @page_templates = Cavy::PageTemplate.all
    end

    def new
      @page_template = Cavy::PageTemplate.new
    end

    def create
      @page_template = Cavy::PageTemplate.new(page_template_params)
      if @page_template.save
        redirect_to admin_page_templates_path, notice: 'Page Template was successfully created.'
      else
        render action: 'new'
      end
    end

    def edit
      @page_template = Cavy::PageTemplate.find(params[:id])
    end

    def update
      @page_template = Cavy::PageTemplate.find(params[:id])

      if @page_template.update(page_template_params)
        redirect_to admin_page_templates_path, notice: 'Page Template was successfully updated.'
      else
        render action: 'edit'
      end
    end

    def delete
      @page_template = Cavy::PageTemplate.find(params[:id])
      @page_template.destroy
      redirect_to admin_page_templates_path, notice: 'Page Template was successfully destroyed.'
    end

    private

    def page_template_params
      params.require(:page_template).permit(:name, :template)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cavy-0.1.0.beta2 app/controllers/cavy/admin_page_templates_controller.rb