Support Rails 4.0

This pull request is the changes to support Rails 4.0.

Currently, all of the tests (only activerecord and sqlite3) are green on both of Rails 3.2.8 and 4.0.0.beta1.