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

55 lines
1.2 KiB
Ruby
Raw Normal View History

class Admin::ComponentsController < ApplicationController
layout "admin"
before_filter :authenticate_user!
before_filter :find_parent_item
def show
#TODO
end
def new
@component = Component.new
@component.is_published = true
2010-01-18 07:52:52 +00:00
@component.parent_name = @parent_item.name
@component.engine_name = 'Announcement' # only support Announcement now
end
def edit
@component = Component.find(params[:id])
end
def create
@component = Component.new(params[:component])
if @component.save
flash[:notice] = 'Component was successfully created.'
2010-01-18 07:52:52 +00:00
redirect_to admin_items_url( :parent_name => @component.parent_name )
else
render :action => "new"
end
end
def update
@component = Component.find(params[:id])
if @component.update_attributes(params[:component])
flash[:notice] = 'Component was successfully updated.'
2010-01-18 07:52:52 +00:00
redirect_to admin_items_url( :parent_name => @component.parent_name )
else
render :action => "edit"
end
end
def destroy
@component = Component.find(params[:id])
@component.destroy
#TODO: destroy engine data
2010-01-18 07:52:52 +00:00
redirect_to admin_items_url( :parent_name => @component.parent_name )
end
end