Reputation: 12475
I have 2 a models
-product (width an boolean attribute named "active")
-variant
product has many variants
so if i do this:
p = Product.first
p.active = false
p.save
p = Product.first
p.active = true
v = p.variants.first
v.product.active is equal to false
why?
How can i read the last setted active's value without save the table product?
thanks
I'm using ruby ree 1.8.7
Upvotes: 2
Views: 41
Reputation: 107728
You cannot do this at the moment in Rails 3.0, although it may be possible in Rails 3.1 due to the identity map. You will have to save the object to the database before you can read the attribute like that.
Upvotes: 2