Ruby On Rails - « undefined метод ʻid 'для 4: Fixnum »

Недавно я решил, что хочу перечислить всех пользователей в моем приложении Ruby On Rails - так как я не мог понять, как перечислить их другим способом, Решил использовать частичные. I have the following on my administration page (just hooked up to a its own administration controller):

<%= render :partial => User.find(:all) %>

I then have a file called _user.html.erb in my users view folder. This contains the following:

<ul>
<% div_for @user.object_id do %>
    <li><%= link_to user.username, user.username %></li>
<% end %>
</ul>

When the application runs and I go to the administration page, I get the following error:

undefined method `id' for 4:Fixnum

It says it's because of this line (which is in the partial file):

<% div_for @user.object_id do %>

I'm unsure why this happens (and have googled for hours to try and find results and only find solutions that don't work for me). I think it's something to do with my usage of the @user instance variable, but I'm not totally sure.

5
задан intcreator 19 July 2017 в 01:24
поделиться