This repository has been archived on 2024-03-16. You can view files and clone it, but cannot push or open issues or pull requests.
orbit-4-1/app/controllers/admin/snippets_controller.rb

53 lines
1.1 KiB
Ruby

class Admin::SnippetsController < ApplicationController
layout "admin"
before_filter :authenticate_user!
before_filter :find_parent_item
before_filter :is_admin?
#Snippet is a object admin user can define his own tag and being used later on in parser
def show
#TODO
end
def new
@snippet = Snippet.new
@snippet.parent_id = @parent_item.id
end
def edit
@snippet = Snippet.find(params[:id])
end
def create
@snippet = Snippet.new(params[:snippet])
if @snippet.save
flash[:notice] = t('admin.create_success_snippet')
redirect_to admin_items_url( :parent_id => @snippet.parent_id )
else
render :action => "new"
end
end
def update
@snippet = Snippet.find(params[:id])
if @snippet.update_attributes(params[:snippet])
flash[:notice] = t('admin.update_success_snippet')
redirect_to admin_items_url( :parent_id => @snippet.parent_id )
else
render :action => "edit"
end
end
def destroy
@snippet = Snippet.find(params[:id])
@snippet.destroy
redirect_to admin_items_url( :parent_id => @snippet.parent_id )
end
end