Error: undefined method 'klass' for nil:NilClass.