问题描述:

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>

"

"

Why I see '0'?

网友答案:

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.

相关阅读:
Top