app.preferences.setIntegerPreference() does not work
app.preferences.setIntegerPreference("rulerType", 0) changes the selection in the GUI but doesn't actually apply the change to the document.
I still have to go into the GUI preferences, change the units to something else, then back to inches and close for the change to actually apply to the current document.
Yes, alas :(
rulerType and text/units are pretty broken in scripting.
Sergey Osokin once mentioned it in his article about accessing Illustrator Preferences, in the end of it: