Fixes for rails 4

I took @TikiTDO 's #10 and made further changes, which fixes all the problems for us. I think, this solves @doliveirakn's doubts about merging the scopes mentioned in #7. If possible, please merge this in rails-4 branch, then we can think about getting it in master and publishing on rubygems.