Skip to content

Instantly share code, notes, and snippets.

@Killavus
Created May 30, 2014 11:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Killavus/c2d304c7737711397daa to your computer and use it in GitHub Desktop.
Save Killavus/c2d304c7737711397daa to your computer and use it in GitHub Desktop.
class Threats::SubscriptionsController < ApplicationController
def show
if current_user.role.analyst?
view_data = service.view_data(params[:threat_id])
render locals: {threat: view_data.threat, categories: view_data.categories}
else
redirect_to root_path, alert: 'You are not allowed to access this page.'
end
end
def update
if current_user.role.analyst?
respond_with service.(params[:threat_id], params[:threat]), location: threats_path, notice: "Threat subscriptions were updated successfully."
else
redirect_to root_path, alert: 'You are not allowed to access this page.'
end
end
private
def service
SubscribeThreatToServiceArea.new(Threat, ServiceArea)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment