| Here's an annoying little thing that led me to | | | | user now clicks "submit," that old data is going to |
| posting this tip today: Firefox has an | | | | overwrite the new data in those fields. |
| autocomplete feature that keeps any form fields | | | | That's bad news when you're trying to maintain |
| you've edited on a page filled with the same data | | | | data integrity. |
| if you refresh the page. This is great if you're | | | | So how do you fix it? |
| say, ordering plane tickets and need to refresh | | | | Well, there is the ability to add to html form |
| for some reason because everything you've | | | | objects this piece of code:autocomplete="off" |
| changed will still be there once the page reloads. | | | | This effectively tells Firefox to ignore the caching |
| But this feature became a problem for me today | | | | that it would normally do to set itself up to |
| while I was working on a project. The core of the | | | | autocomplete the field if a refresh occurs. To |
| project is that it is a rating system for a series of | | | | achieve this same change in Rails, you must add |
| short data pieces that are randomly loaded each | | | | the Ruby version of that code to every form |
| time the page is loaded, with the ability to both | | | | element that you want Firefox to ignore. |
| edit the data and submit the rating simultaneously. | | | | So to make a text_field form helper have |
| Therefore, if you were to click refresh on the | | | | Firefox autocomplete turned off, you would use |
| page, a new random data piece would be loaded. | | | | code like this: |
| This is all well and good, but when you throw in | | | | "off" %> |
| the Firefox autocomplete system into the mix, | | | | To do the same thing for a collection_select |
| things get all messy. | | | | helper, you need to add the autocomplete option |
| What I found was that if a user was editing a | | | | to the html_options hash that is passed to the |
| data piece, then for whatever reason clicked | | | | helper like this: |
| refresh, a new data piece would be randomly | | | | "off"} %> |
| loaded for the next page load, but the editing | | | | Hopefully this little tip will help some people out |
| fields that had data that was modified in it from | | | | because I know it drove me crazy today as I |
| before the refresh will still have that same data in | | | | thought my app was all messed up but it turned |
| those fields. So you've loaded a new data piece, | | | | out to be the browser. |
| but the old edited data is still in the fields, so if the | | | | |