osem-fcy/app/controllers/admin/targets_controller.rb

26 lines
843 B
Ruby
Raw Normal View History

module Admin
class TargetsController < Admin::BaseController
2014-08-12 11:51:59 +03:00
load_and_authorize_resource :conference, find_by: :short_title
authorize_resource through: :conference
def index
2014-08-12 11:51:59 +03:00
authorize! :index, Target.new(conference_id: @conference.id)
end
def update
2014-08-12 11:51:59 +03:00
authorize! :update, @conference => Target
if @conference.update_attributes(params[:conference])
redirect_to(admin_conference_targets_path(
conference_id: @conference.short_title),
notice: 'Targets were successfully updated.')
else
redirect_to(admin_conference_targets_path(
conference_id: @conference.short_title),
alert: 'Targets update failed: ' \
"#{@conference.errors.full_messages.join('. ')}")
end
end
end
end