Ruby On Rails - "undefined method `id' for 4:Fixnum" -


i decided wanted list users in ruby on rails application - since couldn't figure out how list them other way, decided use partials. have following on administration page (just hooked own administration controller):

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

i have file called _user.html.erb in users view folder. contains following:

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

when application runs , go administration page, following error:

undefined method `id' 4:fixnum

it says it's because of line (which in partial file):

<% div_for @user.object_id %> 

i'm unsure why happens (and have googled hours try , find results , find solutions don't work me). think it's usage of @user instance variable, i'm not totally sure.

you error because div_for expects active record object argument, calls id method on. pass in fixnum (the result of @user.object_id), not active record object , not have id method.

so pass in @user instead of @user.object_id , work.

also should use user instead of @user, rails 3 not set instance variables partials anymore.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -