lib/nitro/helper/xhtml.rb in nitro-0.30.0 vs lib/nitro/helper/xhtml.rb in nitro-0.31.0
- old
+ new
@@ -11,11 +11,11 @@
if obj.is_a?(Symbol) or obj.is_a?(String)
href = obj.to_s
elsif obj.respond_to? :to_href
href = obj.to_href
else
- href = "#{obj.class.name.pluralize.undescore}/#{obj.oid}"
+ href = "#{obj.class.name.pluralize.underscore}/#{obj.oid}"
end
if base
base += '/'
else
@@ -61,11 +61,12 @@
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
+ selected = options[:selected]
+ selected = selected.to_s if selected
labels.each_with_index do |label, idx|
value = values[idx]
if options[:style]
style = if options[:style].is_a?(Array)
@@ -73,10 +74,10 @@
else
options[:style]
end
style = %{ style="#{style}"}
end
- if value == selected
+ if value.to_s == selected
str << %|<option value="#{value}" selected="selected"#{style}>#{label}</option>|
else
str << %|<option value="#{value}"#{style}>#{label}</option>|
end
end