before_save and create

Hi,

I have a strange problem with before_save and create.

In my controller I have:

self.current_cart = Cart.create(:user_id => current_user.id, :status => CURRENT_CART)
self.current_cart.update_attributes({:order_num => self.current_cart.id + seed_num })

This works well until I add a before_save in the model:

def before_save
self.is_cached = false
end

Now I get an error in the update_attributes call that self.current_cart.id is nil. Any idea why this could happen?

Thanks,

Ram

_attributes({:order_num => self.current_cart.id + seed_num })

This works well until I add a before_save in the model:

def before_save
  self.is_cached = false
end

Now I get an error in the update_attributes call that
self.current_cart.id is nil. Any idea why this could happen?

if a before_save callback returns false then the save is cancelled

Fred