A nil object when you didn't expect it!

I’m a new ruby, now i have a newbie problem

I have three model
1.

class SfProduct < ActiveRecord::Base
  has_many :sf_actions_maps
    def sf_add_user_to_action_map()
    sf_actions_maps << SfProductMap.new()
  end
end
class SfProductMap < ActiveRecord::Base
  belongs_to :sf_product
  belongs_to :sf_user
class SfUser < ActiveRecord::Base
  has_many :sf_products_maps

product controller create code :
def create
@sf_product = SfProduct.new()
@sf_product.sf_add_user_to_action_map(@sf_user)
respond_to do |format|
if @sf_activity.save

  else

  end
end

afert user the create actions, the error will be show:

You have a nil object when you didn’t expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.delete

please help me!

On 15 April 2011 11:08, seth shao [email protected] wrote:

end
has_many :sf_products_maps

end
end

afert user the create actions, the error will be show:

You have a nil object when you didn’t expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.delete

The error message should tell you which line of your code is failing.
On that line you have probably used a variable that is nil. Possibly
you have done a find and it has not found any records.

If you can’t see it post the whole error message and stack trace and
the bit of code around the error.

Colin