app/controllers/rails_ext.rb in damagecontrol-0.5.0.1393 vs app/controllers/rails_ext.rb in damagecontrol-0.5.0.1404

- old
+ new

@@ -28,10 +28,17 @@ # def find_selected(name) array = instantiate_array_from_hashes(@params[name]) selected = @params["#{name}_selected"] selected_object = array.find { |o| o.class.name == selected } + unless selected_object + Log.error "No selected object among '#{name}'" + Log.error "params: #{@params[name].inspect}" + Log.error "array: #{array.inspect}" + Log.error "selected: #{selected}" + raise "No selected object found. See log for details." + end def selected_object.selected? true end selected_object end @@ -198,9 +205,12 @@ html_value = text_or_input(edit, :name => "#{collection_name}[#{o.class.name}][#{attr_name}]", :value => attr_value) r << " <td width='75%'>#{html_value}</td>\n" r << " </tr>\n" end end + # workaround for RoR bug. 'hash' form params must have at least one value. + r << "<tr><td></td><td><input type='hidden' name ='#{collection_name}[#{o.class.name}][__dummy]'></td></tr>" if o.instance_variables.empty? + r << "</table>" r end end