Hi all Heres what I am trying to do, I have a table that has a process and it has process_details process has_many process_details, foreign_key => :process_id process_detail belongs_to process each process has a number that is associated with it, the step it is 1,2,3,4 . . .. Now the steps can be changed if the process changes, for example step 3 becomes step 1 . My algorithm is trying to update each record in before_save that would need to be change to keep the ordering . (1,2 would be change to 2,3 respectively) the problem is is that I am calling update in before save which initiates before save again. if anyone has an ideas to stop the recursiveness of this call or another way to keep the ordering please tell me, all help is appreciated. White Wizzard --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
self.attributes[field_name] = value - this doesnt call the before save method regards ivor On 10/4/07, White Wizzard <The.White.Wizzard-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > Hi all > > Heres what I am trying to do, I have a table that has a process and it > has process_details > > process > has_many process_details, foreign_key => :process_id > > process_detail > belongs_to process > > each process has a number that is associated with it, the step it is > 1,2,3,4 . . .. > Now the steps can be changed if the process changes, for example step > 3 becomes step 1 . My algorithm is trying to update each record in > before_save that would need to be change to keep the ordering . (1,2 > would be change to 2,3 respectively) the problem is is that I am > calling update in before save which initiates before save again. > > if anyone has an ideas to stop the recursiveness of this call or > another way to keep the ordering please tell me, all help is > appreciated. > > > White Wizzard > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 10/4/07, White Wizzard <The.White.Wizzard-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi all > > Heres what I am trying to do, I have a table that has a process and it > has process_details > > process > has_many process_details, foreign_key => :process_id > > process_detail > belongs_to process > > each process has a number that is associated with it, the step it is > 1,2,3,4 . . .. > Now the steps can be changed if the process changes, for example step > 3 becomes step 1 . My algorithm is trying to update each record in > before_save that would need to be change to keep the ordering . (1,2 > would be change to 2,3 respectively) the problem is is that I am > calling update in before save which initiates before save again. > > if anyone has an ideas to stop the recursiveness of this call or > another way to keep the ordering please tell me, all help is > appreciated.Stepping back from the tree to the forest. Have you considered using acts_as_list? -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
-----Original Message----- From: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org [mailto:rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org] On Behalf Of White Subject: [Rails] before save infinite loop>if anyone has an ideas to stop the recursiveness of this call oranother way to keep the ordering please tell me, all help is appreciated.< Couple of things. First, do you have to use before_save? Can you do the work in update and create by calling a reordering method? Second, you may find a linked list approach is better than explicit ordinals. ///ark --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks for the help all, I have switched to using acts as list process has_many process_details, :order => :position, foreign_key => :process_id process_detail belongs_to process acts_as_list :scope => :process_id and I can view as a list. Thanks Now I am working on, if data is entered into the and a position is specified, I need to enter in this data into that particular position and move the rest of the data down. for example I have a list with 5 steps 1 2 3 4 5 and I insert a step with a position of 2 i want it to insert it into two and move all the other ones down one(increment the position) 1 2 (new Record) 3(was 2) 4(was 3) 5(was 4) 6(was 5) but what i get is 1 2 3 4 5 6 <= new record I will be searching the forums but if the is an easy way to do this please let me know. All help is appreciated White Wizzard --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 10/4/07, White Wizzard <The.White.Wizzard-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:>And I can view as a list. Thanks > > Now I am working on, if data is entered into the and a position is > specified, I need to enter in this data into that particular position > and move the rest of the data down. > > for example I have a list with 5 steps > 1 > 2 > 3 > 4 > 5 > and I insert a step with a position of 2 i want it to insert it into > two and move all the other ones down one(increment the position) > 1 > 2 (new Record) > 3(was 2) > 4(was 3) > 5(was 4) > 6(was 5) > but what i get is > 1 > 2 > 3 > 4 > 5 > 6 <= new record > > I will be searching the forums but if the is an easy way to do this > please let me know.How are you inserting it? If you are setting the position field directly that won''t work, the list elements are always added to the bottom via a before_create callback. I think you need to create it and then call the insert_at method on the model object to move it. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---