Skip to content

Instantly share code, notes, and snippets.

@maxim
Created September 16, 2009 01:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxim/187806 to your computer and use it in GitHub Desktop.
Save maxim/187806 to your computer and use it in GitHub Desktop.
def has_role?(role, object)
if object.has_association?(role)
if has_many?
object.roles.find(self.id)
else
object.role.id == self.id
end
else
self.roles.include?(role)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment