Search code examples
ruby-on-railsmongoid

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


I'm using mongoid-enum gem exactly like the spec

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

  enum medium: [:google, :facebook]
end

and when I run AdVariation.new I get:

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

The repo isn't maintained and doesn't answer questions/bugs

Did anyone stumble upon this?

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

Solution

  • turns out the documentation on the gem is wrong. The right way is:

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