Skip to content

Instantly share code, notes, and snippets.

@aaronmcadam
Forked from patmaddox/authorized_controller.rb
Created August 13, 2014 09:52
Show Gist options
  • Save aaronmcadam/82db8cfc2339773c1d99 to your computer and use it in GitHub Desktop.
Save aaronmcadam/82db8cfc2339773c1d99 to your computer and use it in GitHub Desktop.
module AuthorizedController
# ... full code in the paid lesson
def show
resource = resource_by_id
if resource.viewable_by?(current_user)
render json: resource
else
render text: 'Unauthorized', status: :unauthorized
end
end
# ... full code in the paid lesson
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment