Prev: [ANN] unicorn 0.93.2 - more compatible with Rails
Next: unicorn 0.93.2 - more compatible with Rails
From: Tom Stuart on 7 Oct 2009 11:42 > 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)
|
Pages: 1 Prev: [ANN] unicorn 0.93.2 - more compatible with Rails Next: unicorn 0.93.2 - more compatible with Rails |