Topic: I've inherited a RoR app with a very strange bug

Our stores use a Rails form for nightly reconciliation. Too often, after this form is filled in, (No submit button, uses Ajax to send each field on change) when the same form is viewed by accounting, some of the numbers are either duplicated in other fields, or the numbers have been changed dramatically.

My question is, could this be caused by caching? or? I don't see anything obviously wrong with the code...
Some of the javascript files get included more that once, would that cause problems?


Any suggestions on possible sources for this problem?


  <%= javascript_include_tag :all %>

When the page loads, here are the scripts being included:

<script src="/javascripts/prototype.js?1240294709" type="text/javascript"></script>
<script src="/javascripts/effects.js?1240294709" type="text/javascript"></script>
<script src="/javascripts/dragdrop.js?1240294709" type="text/javascript"></script>
<script src="/javascripts/controls.js?1240294709" type="text/javascript"></script>
<script src="/javascripts/currency.js?1241674982" type="text/javascript"></script>
<script src="/javascripts/datepicker.js?1238790588" type="text/javascript"></script>
<script src="/javascripts/headers.js?1273551417" type="text/javascript"></script>
<script src="/javascripts/application.js?1240294709" type="text/javascript"></script>
<script src="/javascripts/prototype.js?1240294709" type="text/javascript"></script>
<script src="/javascripts/effects.js?1240294709" type="text/javascript"></script>
<script src="/javascripts/dragdrop.js?1240294709" type="text/javascript"></script>
<script src="/javascripts/controls.js?1240294709" type="text/javascript"></script>
<script src="/javascripts/application.js?1240294709" type="text/javascript"></script>
<script src="/javascripts/currency.js?1241674982" type="text/javascript"></script>
<script src="/javascripts/datepicker.js?1238790588" type="text/javascript"></script>
<script src="/javascripts/employeeutil.js?1241351273" type="text/javascript"></script>
<script src="/javascripts/headers.js?1273551417" type="text/javascript"></script>
<script src="/javascripts/stores.js?1241516187" type="text/javascript"></script>

There is only on of each script in the folder, yet duplicates are being included.
Where would these duplicate scripts be getting included from, if not the layout?

In the log I see errors when values are changed (which re-submits them):

ActiveRecord::StatementInvalid: Mysql::Error: Duplicate entry '8-1-4' for key 'hti': INSERT INTO `items` (`header_id`, `amount`, `itemtype_id`, `term_num`, `update_ts`) VALUES(8, 888.88, 4, 1, NULL)

Last edited by mtb24 (2010-09-01 15:27:44)

Re: I've inherited a RoR app with a very strange bug

Yes that would be a problem!!.
If the "submit" function is loaded more then once it get's called more then once! tongue