Find Returning String Instead of Integer?

Any ideas on why this is? The quantity field in mysql is INT, but I get
back a string? This is preventing me from using the increment method.

@cart = Cart.new
=> #<Cart:0x2730f40 @new_record=true, @attributes={}>

@cart.items << Item.find(:first)
=> [#<Item:0x272d6ec @attributes={“vendor_id”=>“1”,
“updated_at”=>“2006-09-26 12:00:38”, “catalog_id”=>“8050”,
“price”=>“185”, “created_by”=>“Unit Tests”, “unit”=>“ea”,
“updated_by”=>nil, “id”=>“1”, “description”=>“CAP analog for SP6
MegaScript kit”, “created_at”=>nil}>]

@cart.save
=> true

@cart.items.find(1).quantity
=> “1”

@cart.items.find(1).increment!(:quantity)
TypeError: can’t convert Fixnum into String
from
/usr/local//lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/base.rb:1445:in
+' from /usr/local//lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/base.rb:1445:inincrement’
from
/usr/local//lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/base.rb:1451:in
`increment!’
from (irb):8

Using

Rails 1.1.6
Mac OS 10.4.7
mysql Ver 14.7 Distrib 4.1.20, for apple-darwin8.5.1 (i686) using
readline 4.3

mysql> desc carts_items;
±---------±--------±-----±----±--------±------+
| Field | Type | Null | Key | Default | Extra |
±---------±--------±-----±----±--------±------+
| cart_id | int(11) | | | 0 | |
| item_id | int(11) | | | 0 | |
| quantity | int(11) | | | 1 | |
±---------±--------±-----±----±--------±------+
3 rows in set (0.10 sec)

mysql> desc carts;
±------±--------±-----±----±--------±---------------+
| Field | Type | Null | Key | Default | Extra |
±------±--------±-----±----±--------±---------------+
| id | int(11) | | PRI | NULL | auto_increment |
±------±--------±-----±----±--------±---------------+
1 row in set (0.00 sec)

mysql> desc items;
±------------±-------------±-----±----±--------±---------------+
| Field | Type | Null | Key | Default | Extra |
±------------±-------------±-----±----±--------±---------------+
| id | int(11) | | PRI | NULL | auto_increment |
| vendor_id | int(11) | YES | | NULL | |
| catalog_id | varchar(255) | YES | | NULL | |
| description | varchar(255) | YES | | NULL | |
| unit | varchar(255) | YES | | NULL | |
| price | float | YES | | NULL | |
| created_at | datetime | YES | | NULL | |
| updated_at | datetime | YES | | NULL | |
| created_by | varchar(255) | YES | | NULL | |
| updated_by | varchar(255) | YES | | NULL | |
±------------±-------------±-----±----±--------±---------------+
10 rows in set (0.00 sec)

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs