osem-fcy/app/controllers/admin/commercials_controller.rb
chrisbr 58974d6914 Implement simplified commercials workflow
It's now possible to simply enter the url of the third party provider to enter a commercial.
2015-04-22 21:30:32 +02:00

52 lines
1.6 KiB
Ruby

module Admin
class CommercialsController < Admin::BaseController
load_and_authorize_resource :conference, find_by: :short_title
load_and_authorize_resource through: :conference, except: [:new, :create]
def index
@commercials = @conference.commercials
@commercial = @conference.commercials.build
authorize! :create, @commercial
end
def create
@commercial = @conference.commercials.build(commercial_params)
authorize! :create, @commercial
if @commercial.save
redirect_to admin_conference_commercials_path,
notice: 'Commercial was successfully created.'
else
redirect_to admin_conference_commercials_path,
error: "An error prohibited this Commercial from being saved: #{@commercial.errors.full_messages.join('. ')}."
end
end
def update
if @commercial.update(commercial_params)
redirect_to admin_conference_commercials_path,
notice: 'Commercial was successfully updated.'
else
redirect_to admin_conference_commercials_path,
error: "An error prohibited this Commercial from being saved: #{@commercial.errors.full_messages.join('. ')}."
end
end
def destroy
@commercial.destroy
redirect_to admin_conference_commercials_path, notice: 'Commercial was successfully destroyed.'
end
def get_html
render text: Commercial.get_content(params[:url])
end
private
def commercial_params
#params.require(:commercial).permit(:commercial_id, :commercial_type)
params[:commercial]
end
end
end