undefined method `Type' for nil:NilClass