Forum: Ruby on Rails sqlite sets a new model's id to 0 after a save

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
720fde074c77f4c9692dd6f05802d581?d=identicon&s=25 Nithin Reddy (Guest)
on 2006-02-25 01:02
(Received via mailing list)
Example:

car = Car.new
car.id # is nil
car.save
car.id # is 0

I'm wondering if this is expected behavior, or something wrong with
what I'm doing. If it is not expected behaviour, how do I go about
solving it?
37ae59664e4d6c45b5ec0d8a290133f1?d=identicon&s=25 Matthew Routley (Guest)
on 2006-02-25 16:35
(Received via mailing list)
Hello,

I recently had this problem. According to
http://wiki.rubyonrails.org/rails/pages/HowtoUseSQLite swig is required
to use
sqlite with rails. I used:

sudo port install swig
sudo gem install sqlite3-ruby

which solved my id=0 problem. Perhaps you are having the same issue?

Cheers,
Matt
720fde074c77f4c9692dd6f05802d581?d=identicon&s=25 Nithin Reddy (Guest)
on 2006-02-27 19:42
(Received via mailing list)
Your advice worked, thanks!

I did have swig installed, but it was an older version. Without your
suggesiton, I would have never thought to look into it.

- Nithin
This topic is locked and can not be replied to.