From: Tom Stuart Date: 2009-10-08T00:42:58+09:00 Subject: Re: Wx::Choice Items generated from lookup table, later need id's of choices. >    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? > Caveat emptor... I don't know WxRuby at all. However, the documentation (http://wxruby.rubyforge.org/doc/controlwithitems.html#ControlWithItems_append) mentions a method: Integer append(String item, Object clientData) Parameters: item - String to add. clientData - Client data to associate with the item. and a corresponding: Object get_item_data(Integer n) Parameters: n - The zero-based position of the item. So would this work? @choice = Wx::Choice.new Fruit.find(:all).each {|fruit| @choice.append(fruit, fruit.id)} selected_fruit_id = @choice.get_item_data(@choice.get_selection) fred = Person.create(:name => "Fred", :fruit_id => selected_fruit_id)