I have a view where I am trying to display all the objects in an array. The objects are tickets.
<tbody>
<% @tickets.each do |ticket| %>
<tr>
<td><%= ticket.ticket_number %></td>
<td><%= ticket.title %></td>
<td><%= ticket.product_name %></td>
<td><%= truncate(ticket.description) %></td>
<td><%= ticket.status %></td>
<td><%= link_to "Show", users_ticket_path(ticket) %>
</tr>
<% end %>
</tbody>
My controller is finding all Users that have the same 'reseller_id' as the current User. So say I have 3 Users all under the same Reseller. The 3 Users all have the same 'reseller_id' Here is my controller that doesn't work.
def index
if admin_user?
@test = "HELLO"
all_users = User.find_all_by_reseller_id(current_user.reseller_id)
all_users.each do |u|
@tickets = u.tickets
end
#@tickets = @tickets.paginate(page: params[:page])
else
@test = "WORLD"
@tickets = current_user.tickets.paginate(page: params[:page])
end
end
This saves a blank array. How do I make an array with all the ticket objects?
Thanks