RE: [Rails] Re: ActiveRecord, insert and not auto-incremented primary keys...

Philippe Lang wrote:

class Garden < ActiveRecord::Base
  set_primary_key :code

garden ="code" => 1, "name" => "garden1")

When you use set_primary_key, ActiveRecord maps your key to
the attribute "id" behind the scenes. So you still use "id".

- Mark.

Let's see the problem differently:

The primary key attribute is protected from mass assignment, so can't
be set by passing its value in a hash. Try this instead:

i ="name" => "to inc or not to inc?") = 123