Support Rails 4.2.0 with AMS 0.9

This patch is the same fixes as #655 and #663 for 0-9-stable branch.
Merge pull request #674 from tricknotes/support-rails4.2-for-ams0.9

Support Rails 4.2.0 with AMS 0.9