Rails - solution for records-level acl
I find many plugins which implements access control under controller-methods level, but i have some special situation:
for example, we have PostsController#index
def index
@posts = Posts.all
end
i want to get records with scope -> where(:user_id => current_user.id)
.
This is simple, but i want to do this on acl-level.
Of course scopes and conditions can be much more complex, like -> 'retri开发者_如何学Cve only posts posted in specific country' etc.
The simplest approach would be to solve that via associations and not additional plugins.
current_user.posts.all
country = Country.find(...)
country.posts.all
...
A perfect balance of readability, performance, and flexibility.
精彩评论