Support Rails 4.2.0

This patch is the same fixes as #655 and #663 .
Merge pull request #675 from tricknotes/support-rails4.2

Support Rails 4.2.0