My team trying to trace a strange bug in a Rails (ver 2.3.8) application. A certain view is rendering a search form containing a few <select> controls. These controls are rendered in a Haml (ver. 3.0.18) template and their content is populated from ActiveRecord objects like so (simplified):
%form#search
= collection_select :product, :id, Product.all, :id, :name
= collection_select :product, :vendor_id, Vendor.all, :id, :name
... a few more
Every now and then, at what seems to be both random and rare, the control renders with each <option> being either a random number (suspected to be the ruby’s #object_id for that entry) or values from a different select in the same form, e.g – product’s name select renders with vendor’s names and vice versa. We cannot reproduce this problem but have seen it happen a few times.
Is anyone aware of a possible Haml/Rails bug that could cause this, or has any thoughts as to how we could trace this error further, or obtain some insight into what’s going on? thanks.
I have a similar problem but we are not using Haml. Instead we are using Spring MVC 3.0 with JSP’s. Not very often but users of our site get random values in the select tag. The list which populates this select tag have 7000+ records. I guess it is some thing related to size of the data and browsers fail to populate the exact value. In other words, if the actual value to be selected is 5000th position, the browser renders whatever it has in hand before reaching 5000th position. This might also be a issue with spring tags which are used for rendering a select.
To over come this issue, a work around that i found (may be this is not the best approach) to use a java script to load the exact values.
If you guys come to know exact issue with solution, Please me know as well. Thanks
Amit 🙂