Application I am working has different user roles client, project manager and super user and on landing page they can search for Articles and there is an advanced filter to filter out records after search. Like: Filter by Author.
I want to hide advance filter for client, for that I want to define ability using cancancan.
Currently I am doing it with model methods. These methods return true and false on the basis of user type.
client?
project_manager?
super_user?
Current Code:
<% unless current_user.client? %>
<%=link_to "Advance Search", "#" %>
<%end%>
I want to remove this and use cancancan instead of this.
<%if can? :filter, Article %>
<%=link_to "Advance Search", "#" %>
<%end%>
For this I tried
cannot :filter, Article if user.client?
But this is restricting all users to filter.