Hi,
After playing while with ActiveRecord, I'm surprised it isn't easier to insert data into a table whose primary key is not auto-incremented by the database server.
The following code...
Hi,
After playing while with ActiveRecord, I'm surprised it isn't easier to insert data into a table whose primary key is not auto-incremented by the database server.
The following code...
Philippe Lang wrote:
class Garden < ActiveRecord::Base set_primary_key :code end
garden = Garden.new("code" => 1, "name" => "garden1") garden.save
When you use set_primary_key, ActiveRecord maps your key to the attribute "id" behind the scenes. So you still use "id".
- Mark.