67 lines
1.7 KiB
Ruby
67 lines
1.7 KiB
Ruby
|
class Admin::AnnouncementsController < ApplicationController
|
||
|
|
||
|
layout "admin"
|
||
|
|
||
|
def index
|
||
|
@announcements = Announcement.all
|
||
|
|
||
|
respond_to do |format|
|
||
|
format.html # index.html.erb
|
||
|
format.xml { render :xml => @announcements }
|
||
|
end
|
||
|
end
|
||
|
|
||
|
def new
|
||
|
@announcement = Announcement.new
|
||
|
|
||
|
respond_to do |format|
|
||
|
format.html # new.html.erb
|
||
|
format.xml { render :xml => @announcement }
|
||
|
end
|
||
|
end
|
||
|
|
||
|
def edit
|
||
|
@announcement = Announcement.find(params[:id])
|
||
|
end
|
||
|
|
||
|
def create
|
||
|
@announcement = Announcement.new(params[:announcement])
|
||
|
|
||
|
respond_to do |format|
|
||
|
if @announcement.save
|
||
|
flash[:notice] = 'Announcement was successfully created.'
|
||
|
format.html { redirect_to admin_announcements_path }
|
||
|
format.xml { render :xml => @announcement, :status => :created, :location => @announcement }
|
||
|
else
|
||
|
format.html { render :action => "new" }
|
||
|
format.xml { render :xml => @announcement.errors, :status => :unprocessable_entity }
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
|
def update
|
||
|
@announcement = Announcement.find(params[:id])
|
||
|
|
||
|
respond_to do |format|
|
||
|
if @announcement.update_attributes(params[:announcement])
|
||
|
flash[:notice] = 'Announcement was successfully updated.'
|
||
|
format.html { redirect_to admin_announcements_path }
|
||
|
format.xml { head :ok }
|
||
|
else
|
||
|
format.html { render :action => "edit" }
|
||
|
format.xml { render :xml => @announcement.errors, :status => :unprocessable_entity }
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
|
def destroy
|
||
|
@announcement = Announcement.find(params[:id])
|
||
|
@announcement.destroy
|
||
|
|
||
|
respond_to do |format|
|
||
|
format.html { redirect_to admin_announcements_path }
|
||
|
format.xml { head :ok }
|
||
|
end
|
||
|
end
|
||
|
end
|