aegis icon indicating copy to clipboard operation
aegis copied to clipboard

Default permissions for resources

Open kyleellman opened this issue 13 years ago • 0 comments

I find myself doing this 90% of the time:

resources :model_name do
  reading do
    allow :everyone
  end
  writing do
    allow :user do
      object.id && object.user == user
    end
  end
end

Is there a way to define defaults for the reading and writing blocks and simply override them in a resource?

This way, one could do something like this:

# Use default permissions
resources :public_posts

# Only allow a user to read their own notes (for example)
resources :private_notes do
  reading do
    allow :user do
      object.id && object.user == user
    end
  end
end

Anyone have any ideas?

Thanks.

kyleellman avatar May 11 '12 21:05 kyleellman