Reputation: 33755
I am trying to add a conditional to an if statement in a rails helper.
<%= link_to "Admin", rails_admin_path, :class => "btn btn-success" if user_signed_in? && current_user.has_any_role? :superadmin, :admin %>
That returns a syntax error at that line:
SyntaxError at /
So how do I check to see if the user is signed in, and if they are, which role they have in 1 elegant line?
Thanks.
Upvotes: 0
Views: 53
Reputation: 29870
Try
<%= link_to "Admin", rails_admin_path, :class => "btn btn-success" if user_signed_in? && current_user.has_any_role?(:superadmin, :admin) %>
Upvotes: 1