A have two mongoid models with a simple has_many/belongs_to relationship between them:
class Lot
include Mongoid::Document
has_many :journal_items
end
class JournalItem
include Mongoid::Document
belongs_to :lot
end
The issue is that I can't create a JournalItem
without a Lot
as it seems that mongoid adds a non-null validation on the JournalItem.lot_id
by default.
JournalItem.create!
# raises validation error "Lot can't be blank"
How can I disable it?
I use the mongoid master with Rails 5.