Updated to work with Rails 4 release candidate 1

[This commit](https://github.com/rails/rails/commit/d87966c1c4119dbfa0808d7bd477b59a6b5f232c) in Rails 4 broke this branch of CPK. This Pull Request fixes it, and removes some new deprecation notices that cropped up.

Tests for mysql, postresql, and sqlite3 all pass.

Update: There was also a problem with counting distinct you can see in the 4th commit. I didn't check to see where / how that broke in CPK because of whatever change in Rails, but I did fix it.