orbit-4-2/app/controllers/admin/ad_images_controller.rb

59 lines
1.1 KiB
Ruby
Raw Permalink Normal View History

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
2014-08-21 03:07:08 +00:00
@ad_images = get_sorted_and_filtered("ad_image")
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