I am using Kaminari Paginate to traverse through users and give them an evaluation. However, certain users can only evaluate certain users, not all of them, but I am confused on how to go about this. I tried creating an array of the users I want to display, but it did not work correctly since I am very new with Ruby. I understand that
<% @users.each do |user| %>
is what is traversing through the entire list, but I am not sure how to edit it to my needs. For example, I have a role attribute for each user. I would like users with each role to only evaluate other users with the same role. I have tried doing something like
<% @users.each do |user| if @user.role == 1 %>
but I know that that exact code verbatum won't work the way I'd like, but that's an example of what I want to do if it's possible. In summary, I would like to choose who is in the paginated list. Below is my code that I am trying to do. Each user has a form.
<h2>Back of House Evaluation</h2>
<br> </br>
<% @users.each do |user| %>
<h4> <%= user.name %> </h4>
<h3> Do you have HEART?</h3>
<%= form_for(user) do |f| %>
<% begin %>
<div class="form-group">
<%= f.label :Hunger_for_wisdom %></label
<div class="col-xs-10">
<div class="form-inline">
<div class="form-group">
<%= f.radio_button :current_one, 1 %>
<%= f.label :_1 %>
</div>
<div class="form-group">
<%= f.radio_button :current_one, 2 %>
<%= f.label :_2 %>
</div>
<div class="form-group">
<%= f.radio_button :current_one, 3 %>
<%= f.label :_3 %>
</div>
<div class="form-group">
<%= f.radio_button :current_one, 4 %>
<%= f.label :_4 %>
</div>
<div class="form-group">
<%= f.radio_button :current_one, 5 %>
<%= f.label :_5 %>
</div>
</div>
</div>
<div class="col-md-3 col-md-offset-4">
<%= f.submit "Submit Score", class: "btn btn-default" %>
<% rescue ActionController::RedirectBackError %>
</div>
</div>
<% end %>
<%= paginate @users %>
<% end %>
<% end %>
Thank you so much in advance!!