class Foo
include Mongoid::Document
field :bars, type:Array
end
How to validate that the bars
array is not empty?
class Foo
include Mongoid::Document
field :bars, type:Array
end
How to validate that the bars
array is not empty?
Try the standard presence validator:
class Foo
include Mongoid::Document
field :bars, type: Array
validates :bars, presence: true
end
This works because the presence
validator uses the blank?
method to check the attribute during validation.