Trying to insert a row into a model that has a composite key the generated sql is asking for an array return value from Postgres:
{"city_id"=>"14000", "state_id"=>"17", "name"=>"City of Chicago", "feature_class"=>"Civil", "county_id"=>"031", "census_class_code"=>"C5"}
rake aborted!
PG::Error: ERROR: column "[:state_id, :city_id]" does not exist
LINE 1: ...ES ($1, $2, $3, $4, $5, $6, $7, $8, $9) RETURNING "[:state_i...
^
: INSERT INTO "cities" ("census_class_code", "city_id", "created_at", "geog", "geom", "name", "state_id", "subdivision_code", "updated_at") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9) RETURNING "[:state_id, :city_id]"
Is the returning [:state_id, :city_id] correct?
Postgres table:
Column | Type | Modifiers | Storage | Stats target | Description
-------------------+-----------------------------+-----------+----------+--------------+-------------
city_id | integer | not null | plain | |
state_id | integer | not null | plain | |
name | character varying(255) | | extended | |
subdivision_code | integer | | plain | |
census_class_code | character varying(255) | | extended | |
created_at | timestamp without time zone | not null | plain | |
updated_at | timestamp without time zone | not null | plain | |
geom | postgis.geometry | | main | |
geog | postgis.geometry(Point) | | main | |
Indexes:
"cities_pkey" PRIMARY KEY, btree (city_id, state_id)
City model:
class City < ActiveRecord::Base
self.primary_key = :state_id, :city_id
has_many :addresses
belongs_to :state
has_and_belongs_to_many :zip_codes, foreign_key: [:state_id, :city_id]
has_and_belongs_to_many :counties, foreign_key: [:state_id, :city_id]
attr_accessible :city_id, :name, :state_id, :census_class_code
end
TIA.