I was curious if there was a built in feature in ActiveRecord or a plugin, but I basically have a database for phone numbers. I want a user to be able to make a phone number as main. There can only be one phone number marked as main at all times. Is there something for this? Thanks for your help. -- Posted via http://www.ruby-forum.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 -~----------~----~----~----~------~----~------~--~---
I would use acts_as_list and add a method to return the phone at position 0 (or 1, depending on if acts_as_list is zero or one based). Maybe call the method main_phone. Now to make a phone number the "main" one just set it position to 1 using acts_as_list methods. On May 15, 4:47 pm, Ben Johnson <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> I was curious if there was a built in feature in ActiveRecord or a > plugin, but I basically have a database for phone numbers. I want a user > to be able to make a phone number as main. There can only be one phone > number marked as main at all times. Is there something for this? > > Thanks for your help. > > -- > Posted viahttp://www.ruby-forum.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 -~----------~----~----~----~------~----~------~--~---
Oops. Sorry mixing my zero one based. I mean set it to position 0 of acts_as_list is zero based. On May 15, 5:37 pm, Robert Walker <rwalker...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I would use acts_as_list and add a method to return the phone at > position 0 (or 1, depending on if acts_as_list is zero or one based). > Maybe call the method main_phone. > > Now to make a phone number the "main" one just set it position to 1 > using acts_as_list methods. > > On May 15, 4:47 pm, Ben Johnson <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: > > > I was curious if there was a built in feature in ActiveRecord or a > > plugin, but I basically have a database for phone numbers. I want a user > > to be able to make a phone number as main. There can only be one phone > > number marked as main at all times. Is there something for this? > > > Thanks for your help. > > > -- > > Posted viahttp://www.ruby-forum.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 -~----------~----~----~----~------~----~------~--~---
vpim might help out... On May 15, 2007, at 2:37 PM, Robert Walker wrote:> > I would use acts_as_list and add a method to return the phone at > position 0 (or 1, depending on if acts_as_list is zero or one based). > Maybe call the method main_phone. > > Now to make a phone number the "main" one just set it position to 1 > using acts_as_list methods. > > On May 15, 4:47 pm, Ben Johnson <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: >> I was curious if there was a built in feature in ActiveRecord or a >> plugin, but I basically have a database for phone numbers. I want >> a user >> to be able to make a phone number as main. There can only be one >> phone >> number marked as main at all times. Is there something for this? >> >> Thanks for your help. >> >> -- >> Posted viahttp://www.ruby-forum.com/. > > > >Steve Ross sross-ju+vs0qJmyeQKKlA4PA9hA@public.gmane.org http://www.calicowebdev.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 -~----------~----~----~----~------~----~------~--~---
A bit more specific: parent.children[2].move_to_top and it is zero based by the way. On May 15, 5:38 pm, Robert Walker <rwalker...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Oops. Sorry mixing my zero one based. I mean set it to position 0 of > acts_as_list is zero based. > > On May 15, 5:37 pm, Robert Walker <rwalker...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I would use acts_as_list and add a method to return the phone at > > position 0 (or 1, depending on if acts_as_list is zero or one based). > > Maybe call the method main_phone. > > > Now to make a phone number the "main" one just set it position to 1 > > using acts_as_list methods. > > > On May 15, 4:47 pm, Ben Johnson <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > > wrote: > > > > I was curious if there was a built in feature in ActiveRecord or a > > > plugin, but I basically have a database for phone numbers. I want a user > > > to be able to make a phone number as main. There can only be one phone > > > number marked as main at all times. Is there something for this? > > > > Thanks for your help. > > > > -- > > > Posted viahttp://www.ruby-forum.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 -~----------~----~----~----~------~----~------~--~---