Hello everybody.
Take this code into account:
----------------------------------------------------------------------
class Foo < Sequel::Model
one_to_many :bars
nested_attributes :bars
def validate
super
errors.add "Ble..." if bars.size < 2
end
end
class Bar < Sequel::Model
many_to_one :foo
end
-----------------------------------------------------------------------
If you use nested_attributes for creating a Foo entity with 2 bars all is
good. Later, when you try to update it deleting one bar, validation gives
you an error, because before saving model (in validation step) Foo object
has not deleted yet removed data, so bars.size continues being 2.
Model consistency after nested_attributes updating is kept for all changes
except deletions with ":_delete => true" semantics. Ia have fixed that in
my system with a wrapper plugin above nested_attributes and others, but it
seems that inconsistency is bad behaviour for base Sequel.
What do you think about it?
Thank you for your opinions. Greets.
--
David
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.