-
-
Save kinsteronline/1285151 to your computer and use it in GitHub Desktop.
Smart use of #tap by dhh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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