开发者

problems with changing values

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 t开发者_JAVA百科he table product?

thanks

I'm using ruby ree 1.8.7


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜