nil object?????

Hello i got this:

        <%Payment.find_all.each do |p|%>      <li><a href="#"><%=p.member.name%>-<%=p.payer_id%></a></li>   <%end%> it throw : You have a nil object when you didn't expect it! The error occurred while evaluating nil.name

this means that it couldn't find a member record for that particular instance of a payment object. So for that payment object, userid would be nil, which means you can't dereference it to obtain a user.

A few comments about your code:

1) don't use find_all, it's been deprecated. Use Payment.find(:all) instead 2) put your finders in your controller, that's where they belong. Use @payments = Payment.find(:all) and then in your view do something like <% @payments.each do |payment| %>

but if i do the same in the script/console it just do it fine, but at the end of all it throw the same thing:

i got:

class Payment < ActiveRecord::Base   set_table_name :payments   belongs_to :member, :foreign_key=>:userid end

you don't need to use set_table_name here, the associated table name will by default be called 'payments'

the rails convention for foreign key naming is to use classname_id. So you should get into the habit of using user_id to reference a User object. In this case it doesn't really matter, but you might as well follow convention.

Adam