Skip to content

Instantly share code, notes, and snippets.

@cpjk
Last active August 23, 2016 16:41
Show Gist options
  • Save cpjk/015186c42b674bf7a01f to your computer and use it in GitHub Desktop.
Save cpjk/015186c42b674bf7a01f to your computer and use it in GitHub Desktop.
defmodule Abilities1 do
defimpl Canada.Can, for: User do
def can?(%User{id: user_id}, action, %Testimonial{id: testimonial_id})
when action in [:create], do: true
def can?(%User{id: user_id}, action, %Testimonial{id: testimonial_id})
when action in [:edit], do: true
end
end
defmodule BetterAbilities do
defimpl Canada.Can, for: User do
# We can declare both action permissions in a single statement
def can?(%User{id: user_id}, action, %Testimonial{id: testimonial_id})
when action in [:create, :edit], do: true
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment