Hi, There is a bug that can cause silent safe failures.
The bug is triggered when trying to save a value where Property#valid?(value) is false. In the current releases it fails silently. Must likely the date_hist property with the value 1955 is triggering this behavior. You can verify it with using dm-core from current master branch (it should raise an exception). Regards, Markus On Thu, Aug 16, 2012 at 03:10:33PM -0700, manu wrote: > Hi folks > > I'm building a sinatra app with DataMapper. > > One of my models is misbehaving, but I can't figure out what is wrong. > > Basically when I try to create a new Mission record, it refuses to save it, > but does not give me any kind of error message to help me figure out why. > > When I inspect the record/object, all the data I passed to the properties > are there, but it doesn't create an @id(=nil) or @created_at(=nil), > presumably because it will not create it :/ > > Any idea how I can draw out some more information? > > Here's some info on the model: > > class Mission > include DataMapper::Resource > > property :id, Serial #auto-increment integer key > property :numero, Integer, :required => true > property :nom, String, :required => true > property :briefing, Text, :required => false, :default => "Pas de > briefing" > property :debriefing, Text, :required => false, :default => "Pas de > debriefing" > property :date_hist, DateTime,:required => false > property :created_at, DateTime > > belongs_to :campagne > > has n, :flights > has n, :avatars, :through => :flights > > end > > I use a seed script to create the record: > > m1=Mission.first_or_create(:numero => 5, > :nom => 'La Belle Rouge', > :briefing => 'test', > :debriefing => 'test', > :date_hist => 1955) > > here's what I get in the console when I run the seed script: > > => [#<Mission @id=nil @numero=5 @nom="La Belle Rouge" @briefing="test" > @debriefing="test" @date_hist=1942 @created_at=nil @campagne_id=3 > @promotion_avatar_id=nil @promotion_grade_id=nil @reward_avatar_id=nil > @reward_decoration_id=nil>] > > > Is it something about the relationships that HAVE to be created first > before I can create a Mission record? > > -- > You received this message because you are subscribed to the Google Groups > "DataMapper" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/datamapper/-/YqFKy6fe8lEJ. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/datamapper?hl=en. > -- Markus Schirp Phone: +49 201 / 360 379 14 Fax: +49 201 / 360 379 16 Web: www.seonic.net Email: [email protected] Twitter: twitter.com/_m_b_j_ OS-Code: github.com/mbj Seonic IT-Systems GbR Anton Shatalov & Markus Schirp Altendorferstrasse 44 D-45127 Essen -- You received this message because you are subscribed to the Google Groups "DataMapper" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/datamapper?hl=en.
