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

57 lines
1.2 KiB
Ruby
Raw Normal View History

2014-05-05 04:50:33 +00:00
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"]
2014-05-05 04:50:33 +00:00
end
2014-04-11 07:47:33 +00:00
def show
@ad_banners = Banner.all
2014-04-11 07:47:33 +00:00
@active = Banner.find(params[:id])
render :action => 'index'
end
2014-04-11 07:47:33 +00:00
def new
@ad_banner = Banner.new
render layout: false
2014-04-11 07:47:33 +00:00
end
2014-04-11 07:47:33 +00:00
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
2014-04-11 07:47:33 +00:00
end
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
params.require(:ad_banner).permit!
2014-04-11 07:47:33 +00:00
end
end