Philip Nelson
2008-Apr-03 22:30 UTC
Problem with UUID generated in partial not being unique
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 -
<tr class="order_product" id ="<%= if
order_product.new_record?
UUID.random_create.to_s
else
order_product.id.to_s
end
%>">
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 Nelson
ScotDB Limited
(teamdba-RvFq4O/J5Z7QT0dZR+AlfA@public.gmane.org)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Apr-03 22:51 UTC
Re: Problem with UUID generated in partial not being unique
On 3 Apr 2008, at 23:30, Philip Nelson wrote:> > 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. >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> -~----------~----~----~----~------~----~------~--~--- >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---