Skip to content

Instantly share code, notes, and snippets.

@cmelbye
Created September 15, 2010 00:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cmelbye/580039 to your computer and use it in GitHub Desktop.
Save cmelbye/580039 to your computer and use it in GitHub Desktop.
def restrict_to_owner(application, error = false, &block)
return unless logged_in?
if application.is_owner? current_user
p block
p block.call
block.call
elsif error
flash[:error] = 'You must be an owner of this application to do that.'
redirect_to(application)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment