[Nitro] [BUG?] nitro/helper/xhtml.rb options

Bill Kelly billk at cts.com
Tue Jun 20 23:09:21 EDT 2006


Hi,

I'm wondering if the "to_i" is intentional in the following code:

nitro-0.30.0/lib/nitro/helper/xhtml.rb
-------------------------------------------
  def options(options = {})
    if labels = options[:labels] || options[:labels_values]
      str = ''

      values = options[:values] || options[:labels_values] || (0...labels.size).to_a

      selected = (options[:selected] || -1).to_i
#                                           ^^^^
-------------------------------------------


It's forcing selected to be an integer, but my values are
strings, so the conditional here was always false:

-------------------------------------------
        if value == selected
          str << %|<option value="#{value}" selected="selected"#{style}>#{label}</option>|
        else
          str << %|<option value="#{value}"#{style}>#{label}</option>|
        end

-------------------------------------------


I've removed the to_i, and the method now behaves as expected.


Regards,

Bill





More information about the Nitro-general mailing list