--------------enigF8A523E4DA9E828F11B9B86A
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Hi,

    I'm using ActiveRecord for db access.....

    If I have a table, fruits, with fields ID, name; and values:

    ID,Name
    1,Apple
    2,Orange
    3,Banana

    And another, people, with ID,name, fruit_id

    And I populate a Wx::Choice with these by doing something like

    @choice = Wx::Choice.new
    Fruit.find(:all).each {|fruit| @choice.append(fruit)}

    And then later I want to create a person:

    fred = Person.create(:name => "Fred", :fruit_id => ???)

    What do I put in place of the ??? ?

    I could do Fruit.find_by_name(@choice.get_string_selection), which
works, but in a larger app could lead to lots and lots of lookups, and
in my particular case, wouldn't work in some places as the thing
appended to the Choice is an amalgam of the database fields.

    I could do (@choice.get_selection +1) but that looks a bit ugly, and
just seems wrong.

    I *think* I could subclass Wx::Choice to something that stores the
ID as well as the text to display, but I can see dragons in the distance
that way....

    What's my best option?

Anthony


--------------enigF8A523E4DA9E828F11B9B86A
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkrMsmIACgkQtUxufNRmXkHp9wCgoPOGomIYsicQgBqgtoic6USA
upEAn3XAk8nz6LQK2MtDcEpiocEEAnHg
AR
-----END PGP SIGNATURE-----

--------------enigF8A523E4DA9E828F11B9B86A--