adbanner-test/app/controllers/admin/ad_banners_controller.rb

57 lines
1.2 KiB
Ruby

class Admin::AdBannersController < OrbitAdminController
def index
@banners = Banner.all.page(params[:page]).per(10)
@table_fields = ["Banner Name","Effect","Transition Interval","Transition Speed","Size","Preview"]
end
def show
@ad_banners = Banner.all
@active = Banner.find(params[:id])
render :action => 'index'
end
def new
@ad_banner = Banner.new
render layout: false
end
def create
@ad_banner = Banner.new(banner_params)
if @ad_banner.save
redirect_to admin_ad_banners_url
else
@ad_banner = Banner.new(params[:ad_banner])
render :new
end
end
def edit
@ad_banner = Banner.find(params[:id])
render layout: false
end
def update
@ad_banner = Banner.find(params[:id])
if @ad_banner.update_attributes(banner_params)
redirect_to admin_ad_banners_url, :status => 303
else
render :edit
end
end
def destroy
@ad_banner = Banner.find(params[:id])
@ad_banner.destroy
redirect_to admin_ad_banners_url
end
private
# Never trust parameters from the scary internet, only allow the white list through.
def banner_params
params.require(:ad_banner).permit!
end
end