RailsCasts Pro episodes are now free!
Learn more or hide this
GitHub User: jgarber
If you're getting an endless loop of updating, change to:
One bug to watch out for is selecting a country and state, saving, and then changing it to a country that has no states. The old state will still persist on the object because the state select was emptied, so no value will be POSTed/PUT for state. You can either do .html($("<option>").attr('selected',true)) instead of empty() or you can have a hidden field with the same name, like Rails does for checkboxes.