0

我需要在 mongoid.yml 中设置选项。它在开发中工作,但在 heroku 中的生产给出了忽略警告消息。有没有人有经验以及如何解决这个问题?

W, [2017-04-05T02:04:09.447207 #4]  WARN -- : MONGODB | Unsupported client option 'raise_not_found_error'. It will be ignored.
W, [2017-04-05T02:04:09.449089 #4]  WARN -- : MONGODB | Unsupported client option 'belongs_to_required_by_default'. It will be ignored.
W, [2017-04-05T02:04:09.449176 #4]  WARN -- : MONGODB | Unsupported client option 'consistency'. It will be ignored.

在 mongoid.yml

production:
  clients:
    default:
      uri: <%= ENV['MONGODB_URI'] %>
      options:
        raise_not_found_error: false
        belongs_to_required_by_default: false
        consistency: :strong
4

1 回答 1

0

这是 Mongo db 在尝试查找任何记录并且在数据库中不匹配时给出的错误。为了解决这个

在您的生产配置中添加此行
raise_not_found_error: false

mongoid.yml
production:
  clients:
    default:
      database: database_name
      hosts:
        - localhost:27017
      options:
        read:
          mode: :primary
        max_pool_size: 1
        raise_not_found_error: false
于 2017-04-05T07:18:03.090 回答