marcamillion
marcamillion

Reputation: 33755

Syntax error for if statement

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

Answers (1)

Logan Serman
Logan Serman

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

Related Questions