Rails4 support columns_for_distinct

This pull request supports `columns_for_distinct` method introduced in rails master and 4-0-stable branch.
See rails/rails#6792 for the initial commit.

This pull request has three separate commits.

-  813e722 refactors `distinct` method to works with Rails 4.0.0. see rails/rails#8289
-  e84080f implements `columns_for_distinct` method. see rails/rails#6792.
-  d4c809b `columns_for_distinct` method does not exist in Rails 4.0.0 version.