Skip to content

Instantly share code, notes, and snippets.

@knzai
Created November 23, 2009 19:07
Show Gist options
  • Save knzai/241288 to your computer and use it in GitHub Desktop.
Save knzai/241288 to your computer and use it in GitHub Desktop.
#initializers/authorization.rb
class AR::Base
def editable_by(user)
user.owns?(self) || user.is_admin?
end
def destroyable_by(user)
editable_by(user)
end
#etc...
end
class Note < AR::Base
#def editable_by(user);end
def destroyable_by(user)
super(user) && comments.empty?
end
#etc...
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment