Sha256: 073c98ff8041bfdfddc9f52e4e87d3b2a85fd1b07479d4f58b5373a3c59ada01

Contents?: true

Size: 1.73 KB

Versions: 1

Compression:

Stored size: 1.73 KB

Contents

module Slightcms

  module Admin
    
    class LayoutsController < ApplicationController
    
      layout "slightcms_admin_layouts_list"
      
      # List all layouts
      def index
        @layouts = Slightcms::Layout.find :all
      end
      
      # Render the form for creating a layout
      def new
        @layout = Slightcms::Layout.new
      end
      
      # Create a new assert
      def create
        @layout = Slightcms::Layout.new(params[:slightcms_layout])
        if @layout.save
          flash[:notice] = "The layout was saved successfully."
          redirect_to slightcms_admin_layouts_path
        else
          flash[:error] = "An error occured saving the layout!"
          render :action => :new
        end
      end
      
      # Render the form for edit an existing layout
      def edit
        @layout = Slightcms::Layout.find(params[:id])
      end
      
      # Update an existing layout
      def update
        @layout = Slightcms::Layout.find(params[:id])
        @layout.update_attributes(params[:slightcms_layout])
        if @layout.save
          flash[:notice] = "The layout was saved successfully."
          redirect_to slightcms_admin_layouts_path
        else
          flash[:error] = "An error occured saving the layout."
          render :action => :edit
        end
      end
      
      # Delete an existing layout
      def destroy
        @layout = Slightcms::Layout.find(params[:id])
        if @layout.destroy
          flash[:notice] = "The layout was deleted successfully."
          redirect_to slightcms_admin_layouts_path
        else
          flash[:error] = "An error occured deleting the layout!"
          redirect_to slightcms_admin_layouts_path
        end
      end
      
    end
  
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
slightcms-0.0.11 lib/app/controller/slightcms/admin/layouts_controller.rb