57 lines
1.1 KiB
Ruby
57 lines
1.1 KiB
Ruby
class Admin::AdBannersController < OrbitAdminController
|
|
before_action ->(module_app = @app_title) { set_variables module_app }
|
|
|
|
def index
|
|
@banners = Banner.all
|
|
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
|
|
|