Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
RSpec and CanCan Authorization for Intentional Economics
can :create, Exchange do |exchange|
unless exchange.group
# the presence of group is validated when creating an exchange
# group will be nil for the new method, so allow it
true
else
membership = Membership.mem(person,exchange.group)
unless membership
false
else
account = person.account(exchange.group)
account && (account.authorized? exchange.amount)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.