Rails 4 support

HI,

This pull-request adds Rails 4 support.

Please see commit messages for detailed changes.

Please let me know if you have any questions. I will be glad to answer.