Thanks Chris, this is what I was looking for. Regards
On Sep 26, 11:16 am, Chris Corbyn <[email protected]> wrote: > Hi Teddy, > > The value returned from #errors sort of behaves like a Hash, but you can send > it #to_hash if you need a real Hash. > > irb(main):001:0> u = User.new(:username => 'Chris Corbyn') > => … snip ... > irb(main):002:0> u.save > => false > irb(main):003:0> u.errors.to_hash > => {:username=>["Username is already in use"]} > irb(main):004:0> u.errors[:username] > => ["Username is already in use"] > > Cheers, > > Chris > > On 27/09/2011, at 1:09 AM, Teddy Limousin wrote: > > > > > > > > > Hey guys, > > > I would like to know if there is a way to get a hash with the name of the > > field as key and an array of the error messages > > that the field has after executing valid?, for example: > > > {:name => ['name is required', 'name must be 4 letters long minimum], > > :lastname => ['last name is required']} > > > Thanks. > > > -- > > Teddy Limousin > > > -- > > 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 > > athttp://groups.google.com/group/datamapper?hl=en. -- 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.
