This repository has been archived on 2024-03-16. You can view files and clone it, but cannot push or open issues or pull requests.
orbit-4-1/app/controllers/admin/ad_images_controller.rb

59 lines
1.1 KiB
Ruby

class Admin::AdImagesController < Admin::AdBannersController
before_filter :only => [ :new, :edit ] do
@ad_banners = AdBanner.all
@tags = get_tags
end
def initialize
super
@app_title = "ad_banner"
end
def index
@ad_images = AdImage.all.page(params[:page]).per(10)
end
def edit
@ad_image = AdImage.find(params[:id])
end
def update
@ad_image = AdImage.find(params[:id])
if @ad_image.update_attributes(params[:ad_image])
redirect_to admin_ad_images_url
else
@ad_banners = AdBanner.all
@tags = get_tags
render action: :edit
end
end
def new
@ad_image = AdImage.new
@ad_image.postdate = Date.today
@ad_image.deadline = Date.today + 30
end
def create
@ad_image = AdImage.new(params[:ad_image])
if @ad_image.save
redirect_to admin_ad_images_url
else
@ad_banners = AdBanner.all
@tags = get_tags
@ad_image = AdImage.new(params[:ad_image])
render action: :new
end
end
def destroy
@ad_image = AdImage.find params[:id]
if @ad_image.destroy
redirect_to admin_ad_images_url
end
end
end