ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Article:
  Rolling with Ruby on Rails
Subject:   problem with adding more than one record
Date:   2006-04-25 13:34:01
From:   deepres
Hello,


I've just tested the first part of this tutorial and I'm encountering that error, when I'm trying to add the second record to the database:


Mysql::Error: #23000Duplicate entry '0' for key 1: INSERT INTO categories (`name`) VALUES('ccc')


./script/../config/../vendor/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:120:in `log'
./script/../config/../vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:185:in `execute'
./script/../config/../vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:195:in `insert'
./script/../config/../vendor/rails/activerecord/lib/active_record/base.rb:1733:in `create_without_callbacks'
./script/../config/../vendor/rails/activerecord/lib/active_record/callbacks.rb:261:in `create_without_timestamps'
./script/../config/../vendor/rails/activerecord/lib/active_record/timestamp.rb:30:in `create'
./script/../config/../vendor/rails/activerecord/lib/active_record/base.rb:1712:in `create_or_update_without_callbacks'
./script/../config/../vendor/rails/activerecord/lib/active_record/callbacks.rb:249:in `create_or_update'
./script/../config/../vendor/rails/activerecord/lib/active_record/base.rb:1388:in `save_without_validation'
./script/../config/../vendor/rails/activerecord/lib/active_record/validations.rb:724:in `save_without_transactions'
./script/../config/../vendor/rails/activerecord/lib/active_record/transactions.rb:126:in `save'
./script/../config/../vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:51:in `transaction'
./script/../config/../vendor/rails/activerecord/lib/active_record/transactions.rb:91:in `transaction'
./script/../config/../vendor/rails/activerecord/lib/active_record/transactions.rb:118:in `transaction'
./script/../config/../vendor/rails/activerecord/lib/active_record/transactions.rb:126:in `save'
./script/../config/../vendor/rails/actionpack/lib/action_controller/scaffolding.rb:130:in `create'
./script/../config/../vendor/rails/actionpack/lib/action_controller/base.rb:908:in `perform_action_without_filters'
./script/../config/../vendor/rails/actionpack/lib/action_controller/filters.rb:355:in `perform_action_without_benchmark'
./script/../config/../vendor/rails/actionpack/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
./script/../config/../vendor/rails/actionpack/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'
./script/../config/../vendor/rails/actionpack/lib/action_controller/rescue.rb:82:in `perform_action'
./script/../config/../vendor/rails/actionpack/lib/action_controller/base.rb:379:in `process_without_filters'
./script/../config/../vendor/rails/actionpack/lib/action_controller/filters.rb:364:in `process_without_session_management_support'
./script/../config/../vendor/rails/actionpack/lib/action_controller/session_management.rb:117:in `process'
./script/../config/../vendor/rails/railties/lib/dispatcher.rb:38:in `dispatch'
./script/../config/../vendor/rails/railties/lib/webrick_server.rb:115:in `handle_dispatch'
./script/../config/../vendor/rails/railties/lib/webrick_server.rb:81:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
./script/../config/../vendor/rails/railties/lib/webrick_server.rb:67:in `dispatch'
./script/../config/../vendor/rails/railties/lib/commands/servers/webrick.rb:59
./script/../config/../vendor/rails/activesupport/lib/active_support/dependencies.rb:136:in `require'
./script/../config/../vendor/rails/railties/lib/commands/server.rb:30
script/server:3


I've checked all of my code, I've tried to replace it with the code from tutorial's archive with the same result. It looks like the value of primary key is not being incremented. I can add some more records to my database manually.


I'm the debian user with the latest rails (1.1) installed from the debian packages.


Any help will be appreciated.


Regards
deepres


1 to 1 of 1
1 to 1 of 1