class Panel::AnnouncementsController < ApplicationController before_filter :require_entry_name, :only => [:index, :new] layout "admin" def index @announcements = Announcement.all( :conditions => { :entry_name => params[:entry_name] }) 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