Вопрос

This is my code to get all user with certain role

          <% users = User.all%>
          <% users.each{ |user|%>
              <% if not  user.has_role? 'coach'%>
              <% next%>
              <% end%>  
          <option value="<%=user.id%>"><%=user.first_name%> </option>
          <% }%>

It looks too much code for this simple task. Is there a better way to do this?

Это было полезно?

Решение

It's right on the readme https://github.com/EppO/rolify

User.with_role(:coach)
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top