orbit-basic/app/controllers/panel/announcements_controller.rb

50 lines
1.2 KiB
Ruby
Raw Normal View History

2010-01-11 09:53:44 +00:00
class Panel::AnnouncementsController < ApplicationController
before_filter :require_entry_name, :only => [:index, :new]
layout "admin"
def index
2010-03-01 08:18:28 +00:00
@announcements = Announcement.all( :conditions => { :entry_name => params[:entry_name] })
2010-01-11 09:53:44 +00:00
end
def new
@announcement = Announcement.new
@announcement.entry_name = params[:entry_name]
end
def edit
@announcement = Announcement.find(params[:id])
end
def create
@announcement = Announcement.new(params[:announcement])
if @announcement.save
flash[:notice] = 'Announcement was successfully created.'
redirect_to panel_announcements_path( :entry_name => @announcement.entry_name )
else
render :action => "new"
end
end
def update
@announcement = Announcement.find(params[:id])
if @announcement.update_attributes(params[:announcement])
flash[:notice] = 'Announcement was successfully updated.'
redirect_to panel_announcements_path( :entry_name => @announcement.entry_name )
else
render :action => "edit"
end
end
def destroy
@announcement = Announcement.find(params[:id])
@announcement.destroy
redirect_to panel_announcements_path( :entry_name => @announcement.entry_name )
end
end