1

In view I set validation for roles (gems cancan and rolify).

As example in HAML

=if current_user.has_role? :admin
  = link_to current_user.name, '#' 

Generated HTML

<a href="#">Administrator</a>
"
0




"

Why I see '0'?

Stack Stack
  • 147
  • 1
  • 1
  • 11

1 Answers1

6

You should use a - in front of your if statement, probably:

- if current_user.has_role? :admin
  = link_to current_user.name, '#' 

When you use an = there, it's going to display the result of that expression, which is not what you want.

John Ledbetter
  • 13,557
  • 1
  • 61
  • 80