I have some mongoid document:
class Firm
include Mongoid::Document
embeds_many :offices
validates_presence_of :offices
end
At least one office must be present. It works. However when 'destroy' method called for latest office than firm was saved but not valid anymore..
I can use something like this:
class Office
embedded_in :firm
before_destroy :check_for_latest
def check_for_latest
false if firm.offices.count == 1
end
end
but it's not good way
Any ideas? Thanks!