# Problem with UUID generated in partial not being unique

**URL:** <https://www.ruby-forum.com/t/problem-with-uuid-generated-in-partial-not-being-unique/133821>\
**Category:** Rails\
**Created:** [April 4, 2008, 12:31am UTC](https://www.ruby-forum.com/t/problem-with-uuid-generated-in-partial-not-being-unique/133821 "2008-04-04T00:31:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Philip\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c5a1d2/32.png) [@Philip\_N](https://www.ruby-forum.com/u/Philip_N)\
**Post date:** [April 4, 2008, 12:31am UTC](https://www.ruby-forum.com/t/problem-with-uuid-generated-in-partial-not-being-unique/133821/1 "2008-04-04T00:31:13Z")

</div>

Folks,

I’m using the “uuidtools” package to generate (hopefully) unique values  
for  
IDs within a partial (for products being added to an order form, where  
nothing is saved to the DB until the end).

Unfortunately when I add a new product line (using RJS page.insert.html  
rendering a partial) the new lines added all have the same UUID.

Here’s the code from the (top of the) partial -

If we have a new product added then we generate a UUID. If it is in  
edit  
mode, and we have an existing database record we using the ID of the  
record  
as the ID.

When I generate the page initially it puts one product line in place.  
It has  
a UUID value. When I click my link to add a new line, it has a  
different  
UUID : but adding any further rows still use this second value.

Is there some sort of caching going on ? Or is there some other reason  
?

TIA

## Phil

Philip N.  
ScotDB Limited  
(removed\_email\_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![Philip\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c5a1d2/32.png) [@Philip\_N](https://www.ruby-forum.com/u/Philip_N)\
**Post date:** [April 4, 2008, 12:52am UTC](https://www.ruby-forum.com/t/problem-with-uuid-generated-in-partial-not-being-unique/133821/2 "2008-04-04T00:52:21Z")

</div>

On 3 Apr 2008, at 23:30, Philip N. wrote:

> rendering a partial) the new lines added all have the same UUID.

How exactly are you doing this? if it’s all happening client-side then  
this is to be expected: the partial is only rendered once (how could  
it be rendered more than once if there is no roundtrip to the server.

Fred
