Sha256: b28e7f2ea2a77f99e781819417a59a279da10fbad548d4df860e8ccb9379bc5f

Contents?: true

Size: 1.09 KB

Versions: 11

Compression:

Stored size: 1.09 KB

Contents

module Admin
  class SnippetsController < BaseController
  
    sections 'settings'
  
    def index
      @snippets = current_site.snippets
    end
  
    def new
      @snippet = current_site.snippets.build
    end
  
    def edit
      @snippet = current_site.snippets.find(params[:id])
    end
  
    def create
      @snippet = current_site.snippets.build(params[:snippet])

      if @snippet.save
        flash_success!
        redirect_to edit_admin_snippet_url(@snippet)
      else
        flash_error!
        render :action => 'new'
      end
    end
  
    def update
      @snippet = current_site.snippets.find(params[:id])
      
      if @snippet.update_attributes(params[:snippet])
        flash_success!
        redirect_to edit_admin_snippet_url(@snippet)
      else
        flash_error!
        render :action => "edit"
      end
    end
  
    def destroy
      @snippet = current_site.snippets.find(params[:id])

      begin
        @snippet.destroy
        flash_success!
      rescue Exception => e
        flash[:error] = e.to_s
      end

      redirect_to admin_snippets_url
    end
  
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
locomotive_cms-0.0.2.5 app/controllers/admin/snippets_controller.rb
locomotive_cms-0.0.2.4 app/controllers/admin/snippets_controller.rb
locomotive_cms-0.0.2.3 app/controllers/admin/snippets_controller.rb
locomotive_cms-0.0.2.2 app/controllers/admin/snippets_controller.rb
locomotive_cms-0.0.2.1 app/controllers/admin/snippets_controller.rb
locomotive_cms-0.0.2 app/controllers/admin/snippets_controller.rb
locomotive_cms-0.0.1.4 app/controllers/admin/snippets_controller.rb
locomotive_cms-0.0.1.3 app/controllers/admin/snippets_controller.rb
locomotive_cms-0.0.1.2 app/controllers/admin/snippets_controller.rb
locomotive_cms-0.0.1.1 app/controllers/admin/snippets_controller.rb
locomotive_cms-0.0.1 app/controllers/admin/snippets_controller.rb