Reputation: 33795
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: 54
Reputation: 29880
Try
<%= link_to "Admin", rails_admin_path, :class => "btn btn-success" if user_signed_in? && current_user.has_any_role?(:superadmin, :admin) %>
Upvotes: 1