Fix rails4 deprecation warnings

That appear when running topic_spec.rb
Patch ActiveRecord::Relation#references and clean up
Merge pull request #1336 from novemberkilo/master

First pass at fixing rails4 deprecation warnings