48 lines
1.2 KiB
Ruby
48 lines
1.2 KiB
Ruby
|
class Admin::AdImagesController < ApplicationController
|
||
|
layout 'new_admin'
|
||
|
before_filter :authenticate_user!
|
||
|
before_filter :is_admin?
|
||
|
|
||
|
def edit
|
||
|
@ad_banner = AdBanner.find params[:ad_banner_id]
|
||
|
@ad_image = @ad_banner.ad_images.find params[:id]
|
||
|
end
|
||
|
|
||
|
def update
|
||
|
@ad_banner = AdBanner.find params[:ad_banner_id]
|
||
|
@ad_image = AdImage.find params[:id]
|
||
|
@ad_image.update_attributes(params[:ad_image])
|
||
|
@ad_image.to_save = true
|
||
|
@ad_image.save!
|
||
|
redirect_to admin_ad_banner_path @ad_banner
|
||
|
end
|
||
|
|
||
|
def new
|
||
|
@ad_image =AdImage.new
|
||
|
#render :action => 'new',:url=> {:ad_banner_id => params.has_key?(:ad_banner_id)? params[:ad_banner_id],nil}
|
||
|
end
|
||
|
|
||
|
def create
|
||
|
@ad_banner = AdBanner.find params[:ad_banner][:id]
|
||
|
ad_image = AdImage.new params[:ad_image]
|
||
|
ad_image.to_save = true
|
||
|
@ad_banner.ad_images << ad_image
|
||
|
|
||
|
if @ad_banner.save!
|
||
|
redirect_to admin_ad_banner_path @ad_banner
|
||
|
end
|
||
|
|
||
|
end
|
||
|
|
||
|
def destroy
|
||
|
@ad_banner = AdBanner.find params[:ad_banner_id]
|
||
|
@ad_image = @ad_banner.ad_images.find params[:id]
|
||
|
if @ad_image.destroy
|
||
|
flash[:notice] = t('admin.success_destroy_ad_image')
|
||
|
redirect_to admin_ad_banner_path @ad_banner
|
||
|
end
|
||
|
end
|
||
|
|
||
|
|
||
|
end
|