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.idis nil. Any idea why this could happen?

Thanks,

Ram

On 25 Apr 2008, at 17:41, Ram R. wrote:

if a before_save callback returns false then the save is cancelled

Fred