On 15 June 2011 16:14, Justin Stanczak <[email protected]> wrote: > This whole method runs into a lot of issues. What about has_many objects, > they won't update with new id either. Is there not a method to have rails > add or update based on id in a new object? Is this not how I should be > working with distributed objects?
Have you tried using a before_create filter to force the id to the appropriate value? I have not done this myself but I seem to remember the technique being suggested. Colin > > On Wed, Jun 15, 2011 at 10:47 AM, Justin Stanczak <[email protected]> > wrote: >> >> To narrow down the issue I'm having, I can update an object that exists. >> Like so: >> stu = Student.find('8edcfd63-801c-4ad3-b811-a6bdc440810e') >> #### This will update the obj, but leave the id unchanged >> stu.update_attributes!(JSON.parse(json_string)) >> But this will not work: >> ### Will not find this id >> stu = Student.find('c6a4673e-90bd-4793-a62f-2e2fbdb857f6') >> stu = Student.new >> ### ID will be nil after this update >> stu.update_attributes!(JSON.parse(json_string)) >> ### a forced save false will create a new id, not the one assigned by json >> >> I would think I'm just missing something simple, or how would a >> distributed system work in Rails/Ruby? >> >> > > -- > 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 [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > -- 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

