I want to make some helpers for my rolify methods.
So, I've created the following:
Users helper
module UsersHelper
#Check if current user is admin
def admin_check
if current_user
if current_user.has_role? :admin
end
end
#Check if current user is pro and admin
def admin_and_pro_check
if current_user
if current_user.has_any_role? :admin, :pro
end
end
#Check if current user is pro
def pro_check
if current_user
if (current_user.has_role? :pro) && (current_user.is_pro == true)
end
end
end
end
Now, in my view, how do I use them? Which is the better way?
<%= pro_check do %>
<%= f.input :url, label: "Visto en", placeholder: "www.paginaweb.com" %>
<% end %>
<%= if pro_check %>
<%= f.input :url, label: "Visto en", placeholder: "www.paginaweb.com" %>
<% end %>