ben
1
Hi,
I have a one-to-many relationship. I want to be able to add objects
to the collection w/out persisting them. How do I do this?
The only thing I can’t think of is to use a transaction and roll it
back.
In other words - I want to do this:
o = Order.find(1)
p = Product.find(1)
o.products << p # but don’t persist this
I assume I’m just missing something obvious here. Any ideas?
Thanks,
Ben
ben
2
Hm, maybe clone/dup the object?
ben
3
Ben A. wrote:
I have a one-to-many relationship. I want to be able to add objects
to the collection w/out persisting them. How do I do this?
The only thing I can’t think of is to use a transaction and roll it back.
In other words - I want to do this:
o = Order.find(1)
p = Product.find(1)
o.products << p # but don’t persist this
o.products.to_ary << p
–
We develop, watch us RoR, in numbers too big to ignore.
ben
4
yes, but I still want it to be there as an unpersisted member, so I
get it when I do
o.products.each do |p|
…
end
ben
5
Ben A. wrote:
yes, but I still want it to be there as an unpersisted member, so I
get it when I do
o.products.each do |p|
…
end
On 3/8/06, Mark Reginald J. [email protected] wrote:
o.products.to_ary << p
Hmm, I’m surprised this doesn’t work.
–
We develop, watch us RoR, in numbers too big to ignore.