Fix SQL query for ActiveRecord::Base#can_rate? method