Skip to content

Instantly share code, notes, and snippets.

@kinsteronline
Forked from dhh/gist:1284958
Created October 13, 2011 18:57
Show Gist options
  • Save kinsteronline/1285151 to your computer and use it in GitHub Desktop.
Save kinsteronline/1285151 to your computer and use it in GitHub Desktop.
Smart use of #tap by dhh
def revoke(user)
proxy_association.owner.tap do |project|
# You can't remove the last user with access (someone has to have access to the project!)
if project.users.many?
if user.pending? && user.projects.one?
user.destroy
else
project.users.delete(user)
user.touch
end
project.touch :accesses_updated_at
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment