Forum: Ruby on Rails Way to mark record as main?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
328f0bb678423fcea01ebe3b0edc74e6?d=identicon&s=25 Ben Johnson (benjohnson)
on 2007-05-15 22:47
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.
21f7ed21f11a809050594c82eab11d67?d=identicon&s=25 Robert Walker (Guest)
on 2007-05-15 23:37
(Received via mailing list)
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...@andreas-s.net>
21f7ed21f11a809050594c82eab11d67?d=identicon&s=25 Robert Walker (Guest)
on 2007-05-15 23:39
(Received via mailing list)
Oops.  Sorry mixing my zero one based.  I mean set it to position 0 of
acts_as_list is zero based.
Ef0db53920b243d6758c2f6b1306df0d?d=identicon&s=25 Steve Ross (cwd)
on 2007-05-15 23:40
(Received via mailing list)
vpim might help out...

On May 15, 2007, at 2:37 PM, Robert Walker wrote:

>> I was curious if there was a built in feature in ActiveRecord or a
>
>
> >

Steve Ross
sross@calicowebdev.com
http://www.calicowebdev.com
21f7ed21f11a809050594c82eab11d67?d=identicon&s=25 Robert Walker (Guest)
on 2007-05-15 23:42
(Received via mailing list)
A bit more specific:

parent.children[2].move_to_top

and it is zero based by the way.
This topic is locked and can not be replied to.