Upgrade to rails 3.

This is a major pull request that upgrades the application from rails 2.3.14 to rails 3, including much necessary reimplementation of functionality.