Hello,
I'm would like to know the column name when an error occurs and I'm
iterating over the errors upon a save failure.
I have something like this:
class Message
include DataMapper::Resource
property :id, Serial
property :message_body, String
validates_presence_of :message_body
end
When I create a new instance with message_body missing:
params = {}
message = Message.new(params)
if message.save
else
message.errors.each do |e|
puts e.inspect
end
end
What I see from inspect is:
["Message body must not be blank"]
I would like to get back the exact field / column name as well, something
like:
{ :message_body => ["Message body must not be blank"] }
or even:
["message_body: Message body must not be blank"]
Does anyone know if this can be done? Thanks!
Scott
--
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/-/pbjX-0ntaToJ.
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.