John Tsombakos
2006-Sep-09 23:07 UTC
''id'' not being correctly set when creating new record
(spun off from my problem with acts_as_attachment) I''m seeing a problem where the id is not being set when a record is saved. I set up a new, simple Rails app, with one database table. I try this in the console: ~/RoR/testaaa john$ script/console Loading development environment.>> b=Book.new=> #<Book:0x255cab4 @attributes={"name"=>nil}, @new_record=true>>> b.name="asdf"=> "asdf">> b.save=> true>> b=> #<Book:0x255cab4 @errors=#<ActiveRecord::Errors:0x24344ac @errors={}, @base=#<Book:0x255cab4 ...>>, @attributes={"name"=>"asdf", "id"=>0}, @new_record=false> Now, I''m pretty sure that after saving the id should be set to the id of the record. Looking at the db (sqlite in this case), the id is being properly autoincremented and set: ~/RoR/testaaa john$ sqlite3 db/testaaa_development SQLite version 3.1.3 Enter ".help" for instructions sqlite> select * from books; 1|hsfd Has anyone seen this? I''ve got up to date gems. Thanks! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
John Tsombakos
2006-Sep-10 01:37 UTC
Re: ''id'' not being correctly set when creating new record
On 9/9/06, John Tsombakos <tsom.rails-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> (spun off from my problem with acts_as_attachment) > > I''m seeing a problem where the id is not being set when a record is > saved. I set up a new, simple Rails app, with one database table. I > try this in the console:For anyone else who happens to run into this. Apparently, something changed somewhere to cause sqlite3 and ruby to not work (some details here: http://scottstuff.net/blog/articles/2006/07/01/sqlite-3-and-ruby-finally-working-on-os-x ) I ended up installing SWIG from source (I don''t have Darwinports installed), and removed and reinstalled the sqlite3 gem and it''s all working again. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---