orbit-basic/app/controllers/admin/snippets_controller.rb

51 lines
1.0 KiB
Ruby
Raw Normal View History

class Admin::SnippetsController < ApplicationController
layout "admin"
before_filter :authenticate_user!
before_filter :find_parent_item
before_filter :is_admin?
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])
2010-01-04 09:49:55 +00:00
if @snippet.save
flash[:notice] = t('admin.create_success_snippet')
redirect_to admin_items_url( :parent_id => @snippet.parent_id )
2010-01-04 09:49:55 +00:00
else
render :action => "new"
end
end
def update
@snippet = Snippet.find(params[:id])
2010-01-04 09:49:55 +00:00
if @snippet.update_attributes(params[:snippet])
flash[:notice] = t('admin.update_success_snippet')
redirect_to admin_items_url( :parent_id => @snippet.parent_id )
2010-01-04 09:49:55 +00:00
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
2010-01-04 09:49:55 +00:00
end