2014-05-05 04:50:33 +00:00
|
|
|
class Admin::AdBannersController < OrbitAdminController
|
|
|
|
|
2014-05-09 08:42:23 +00:00
|
|
|
def index
|
2014-07-16 07:20:25 +00:00
|
|
|
@banners = Banner.order_by(sort).page(params[:page]).per(10)
|
|
|
|
@table_fields = ["ad_banner.banner_name","ad_banner.effect","ad_banner.transition_interval","ad_banner.transition_speed","ad_banner.size","preview"]
|
2014-05-05 04:50:33 +00:00
|
|
|
end
|
2014-05-09 08:42:23 +00:00
|
|
|
|
2014-04-11 07:47:33 +00:00
|
|
|
def show
|
2014-05-09 08:42:23 +00:00
|
|
|
@ad_banners = Banner.all
|
2014-04-11 07:47:33 +00:00
|
|
|
@active = Banner.find(params[:id])
|
|
|
|
render :action => 'index'
|
|
|
|
end
|
2014-05-09 08:42:23 +00:00
|
|
|
|
2014-04-11 07:47:33 +00:00
|
|
|
def new
|
2014-05-09 08:42:23 +00:00
|
|
|
@ad_banner = Banner.new
|
|
|
|
render layout: false
|
2014-04-11 07:47:33 +00:00
|
|
|
end
|
2014-05-09 08:42:23 +00:00
|
|
|
|
2014-04-11 07:47:33 +00:00
|
|
|
def create
|
2014-05-09 08:42:23 +00:00
|
|
|
@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
|
2014-04-11 07:47:33 +00:00
|
|
|
end
|
|
|
|
|
2014-05-09 08:42:23 +00:00
|
|
|
def destroy
|
|
|
|
@ad_banner = Banner.find(params[:id])
|
|
|
|
@ad_banner.destroy
|
|
|
|
redirect_to admin_ad_banners_url
|
|
|
|
end
|
|
|
|
|
2014-04-11 07:47:33 +00:00
|
|
|
private
|
|
|
|
|
|
|
|
# Never trust parameters from the scary internet, only allow the white list through.
|
|
|
|
def banner_params
|
2014-05-09 08:42:23 +00:00
|
|
|
params.require(:ad_banner).permit!
|
2014-04-11 07:47:33 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|