【问题标题】:mongoid enum ArgumentError: wrong number of arguments (given 1, expected 2..3)mongoid enum ArgumentError:参数数量错误(给定 1,预期 2..3)
【发布时间】:2021-07-17 09:43:29
【问题描述】:

我正在使用 mongoid-enum gem 与 spec 完全一样

class AdVariation
  include Mongoid::Document
  include Mongoid::Timestamps
  include Mongoid::Enum

  enum medium: [:google, :facebook]
end

当我运行 AdVariation.new 时,我得到:

ArgumentError: wrong number of arguments (given 1, expected 2..3)

repo 未维护,不回答问题/错误

有人偶然发现这个吗?

$ bundle show | grep mongoid
* mongoid (5.4.0)
* mongoid-enum (0.4.0)

【问题讨论】:

  • 你有错误的回溯吗?

标签: ruby-on-rails mongoid


【解决方案1】:

原来 gem 上的文档是错误的。正确的做法是:

enum :medium, [:google, :facebook], default: nil 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-15
    • 1970-01-01
    • 2016-07-01
    • 2023-01-27
    • 2020-12-12
    相关资源
    最近更新 更多