0

Is there anyway to fetch the mysql error in datamapper (I am using Sinatra)

@params = {"product"=>"client", "os"=>"windows", "architecture"=>"32", "version"=>""}
@a = Package.new(@params)
@a.save

@a.save returns me false, because version cannot be null. But How can I retrieve this error message (that mysql must have returned saying version can not be null)?

JVK
  • 3,782
  • 8
  • 43
  • 67

1 Answers1

-1

DataMapper: If your validators find errors in your model, they will populate the Validate::ValidationErrors object that is available through each of your models via calls to your model's errors method.

if @a.save
  #Record saved 
else 
  @a.errors.each do |e|
    puts e
  end
end
Anand Shah
  • 14,575
  • 16
  • 72
  • 110