Skip to content

Instantly share code, notes, and snippets.

@dankohn
Created November 20, 2014 21:43
Show Gist options
  • Save dankohn/e3896f9288d19ac1f7a5 to your computer and use it in GitHub Desktop.
Save dankohn/e3896f9288d19ac1f7a5 to your computer and use it in GitHub Desktop.
def access_own_records
return if @user.super_administrator?
# Anyone can read or update anything they create
[Appointment, Claim, Referral, Study].each do |model|
can([:edit, :index, :read, :update], model,
model.where(created_id: @user.id)) do |instance|
instance.created_id == @user.id
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment