CLC-2709 Rails 4 upgrade

https://jira.ets.berkeley.edu/jira/browse/CLC-2709

This horrific mess brings us into the modern Rails era. The time-consuming part has to do with the core way we do things in a non-Railsy way: our extensive use of custom SQL (which caused CLC-3548). The second most time-consuming part was a date-time bug in Rails, which caused CLC-3568. Fortunately there were workarounds for both of these problems. 

I've tested this with rails c, rails s, torquebox in development mode, and torquebox in production mode (with compiled assets). 

The subtasks of CLC-2709 note some of the difficulties. 

This pull does the bulk of the upgrade, plus it fixes some of the subtasks:
https://jira.ets.berkeley.edu/jira/browse/CLC-3541 
https://jira.ets.berkeley.edu/jira/browse/CLC-3544
https://jira.ets.berkeley.edu/jira/browse/CLC-3548
https://jira.ets.berkeley.edu/jira/browse/CLC-3568

These subtasks remain open and unfixed by this pull:
https://jira.ets.berkeley.edu/jira/browse/CLC-3542
https://jira.ets.berkeley.edu/jira/browse/CLC-3543
https://jira.ets.berkeley.edu/jira/browse/CLC-3565

Please wait for green Bamboo before merging: https://bamboo.ets.berkeley.edu/bamboo/browse/MYB-CLCMVPCHRIS6-14