I am primarily a PHP developer, but recently I came across a Ruby project and was excited about it.
I got my self in to a Sinatra project where things I needed were supposed to be already plugged. It even had the models. It uses SQLite for development. I am trying to create some initial data to work on the rest of the project. I have been able to populate the database, but the decimal fields are remaining nil. Here is what I am trying to do: behzad = User.create({ type: :lender, email: 'beh...@abc.co', password: 'password', password_confirmation: 'password', is_active: true, created_at: Time.new - 60*60*24*12, last_login_at: Time.new, }) i1 = Investment.create({ user: behzad, amount: 500.00, rate: 10.000000, delay: 1, flag: true, created_at: Time.new - 60*60*24*30*3, }) Every thing is alright, except the amount and rate... To print things I wrote this ap object.errors.inspect.split("@") It outputs the following. [ [ 0] "#<DataMapper::Validations::ValidationErrors:0xb0cf200 ", [ 1] "resource=#<User ", [ 2] "id=1 ", [ 3] "created_at=#<DateTime: 2013-05-27T22:55:03+05:30 ((2456440j,62703s,0n),+19800s,2299161j)> ", [ 4] "last_login_at=#<DateTime: 2013-06-08T22:55:03+05:30 ((2456452j,62703s,0n),+19800s,2299161j)> ", [ 5] "type=:lender ", [ 6] "is_active=true ", [ 7] "email=\"behzad", [ 8] "abc.co\" ", [ 9] "password_digest=\"400$8$16$1a1ea55dee98431f$6b1a6eccd7fcded9918b821687f498217468c6dec94561c462554fbec82c7c3a\">, ", [10] "errors={}>" ] [ [0] "#<DataMapper::Validations::ValidationErrors:0xb0fff90 ", [1] "resource=#<Investment ", [2] "id=1 ", [3] "created_at=#<DateTime: 2013-03-10T22:55:03+05:30 ((2456362j,62703s,0n),+19800s,2299161j)> ", [4] "amount=nil ", [5] "rate=nil ", [6] "delay=1 ", [7] "flag=true ", [8] "user_id=1>, ", [9] "errors={}>" ] Note: right on top - *ValidationError* and the rate and amount are nil. I wrapped them in try catch blocks but had no success. I first thought it could be the decimal value and sqlite. But then the why would the *User *object be showing validation errors? Do I need to put the user class here for you to make a guess. By what I understand user class is populated properly. It has many relations though. One such relation is investment. Thanks in advance. -- 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.