ryanb/cancan — Issue #520: controlling record field visibility in a view based on user role
Author: ejalbos
Created: 2011-11-28 23:54:29+00:00
State: open

We have a common display partial for user data. Depending on the role of the logged-in user, they see a possibly restricted information set about certain objects (e.g. the same partial is used to show the user their own data on their account page and we don't show the certain privileged information about themselves).

Right now I have added "has_role?" to User and am calling that in the view
```
<% if current_user.has_role? :superuser %>
```
but what I'd really rather do one of:

* ```<% has_role? :superuser %>``` (like "can?") w/o having to reference the current user

* ```<% can? :access_attr, User, :likability %>``` and specifically be able to say the fields they could or could not see (though not sure what the syntax on this might look like.

Have looked through the docs and didn't see anything. Pls pt me appropriately if I've just missed it.

Thx for a useful gem none the less.