0

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.

1 Answer 1

1

Try

<%= link_to "Admin", rails_admin_path, :class => "btn btn-success" if user_signed_in? && current_user.has_any_role?(:superadmin, :admin) %> 
Sign up to request clarification or add additional context in comments.

1 Comment

Wow....I tried every other permutation with parens but not this. This works. Thanks! Will accept as soon as I can.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.