Skip to content

Instantly share code, notes, and snippets.

@patmaddox
Created August 13, 2014 04:20
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save patmaddox/4bddc564401a110260ae to your computer and use it in GitHub Desktop.
Save patmaddox/4bddc564401a110260ae to your computer and use it in GitHub Desktop.
RubySteps 012 - Rails - Mini frameworks snippet
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