I've got a total of 11 users in my seeds.rb. however, in my user index, it displays 11x11 = 121 users. each user is listed 11 times. Also, whenever I create a new user on the website (sign up), it keeps on multiplying. +1 signed up user leads to a total of 12 users in the db and 12x12 = 144 users being displayed (THEY ARE NOT IN THE DB!) in the index... what's wrong here?! I checked my users controller create action for any weird stuff but couldn't find anything out of the usual.. any help?
this is my user index view:
<% provide(:title, 'Users') %>
<h1>List of Users</h1>
<%= will_paginate %>
<ul class="users">
<% @users.each do |user| %>
<%= render @users %>
<% end %>
</ul>
<%= will_paginate %>
As Solarflare mentioned in the comment, you're rendering the entire user list ( @users
) at every iteration of that loop. You should update your loop to be:
<ul class="users">
<% @users.each do |user| %>
<%= render user %>
<% end %>
</ul>
That way you're rendering the page for each individual user
in the loop.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.