You are asigning foo to the name field... and nothing to the data field... in your model, you declared data as a requires field... if you don't assign anything to it, it's nil... and data must have a value... that's why. On May 23, 2013 11:18 AM, "Nicholas Wieland" <nicholas.wiel...@gmail.com> wrote:
> Hi *, I have a model like this: > > class Trait > include DataMapper::Resource > > property :id, Serial > property :name, Slug, :required => true > property :data, Decimal, :required => true > > has n, :items, :through => :assignments > has n, :assignments > end > > and if I do: > > irb(main):029:0> t = Trait.new > => #<Trait @id=nil @name=nil @data=nil> > irb(main):030:0> t.data = 1.0 > => 1.0 > irb(main):031:0> t > => #<Trait @id=nil @name=nil @data=nil> > irb(main):032:0> t.name = "FOO" > => "FOO" > irb(main):033:0> t > => #<Trait @id=nil @name="foo" @data=nil> > irb(main):034:0> t.save > => false > irb(main):035:0> t.errors.inspect > => "#<DataMapper::Validations::ValidationErrors:0x00000005bb5e40 > @resource=#<Trait @id=nil @name=\"foo\" @data=nil>, @errors={:data=>[\"Data > must not be blank\"]}>" > > can someone explain me why I'm not able to set the data attribute? > > TIA, > ngw > > -- > You received this message because you are subscribed to the Google Groups > "DataMapper" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to datamapper+unsubscr...@googlegroups.com. > To post to this group, send email to datamapper@googlegroups.com. > Visit this group at http://groups.google.com/group/datamapper?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- You received this message because you are subscribed to the Google Groups "DataMapper" group. To unsubscribe from this group and stop receiving emails from it, send an email to datamapper+unsubscr...@googlegroups.com. To post to this group, send email to datamapper@googlegroups.com. Visit this group at http://groups.google.com/group/datamapper?hl=en. For more options, visit https://groups.google.com/groups/opt_out.