check for class primary_key before using id in ActiveModel::Conversion#to_key