class PartyAssociation < ActiveRecord::Base
belongs_to :party, :foreign_key => “source_party_id”
belongs_to :party, :foreign_key => “target_party_id”
end
class CreateParties < ActiveRecord::Migration
def change
create_table :parties do |t|
t.timestamps
end
end
end
class CreatePartyAssociations < ActiveRecord::Migration
def change
create_table :party_associations, :id => false do |t|
t.integer :source_party_id
t.integer :target_party_id
t.timestamps
end
end
end
This RSpec statement:
it “should destroy source associations” do @party.destroy
end
Causes this ERROR MESSAGE:
ActiveRecord::StatementInvalid: SQLite3::SQLException: no such column:
party_associations.: DELETE FROM “party_associations” WHERE
“party_associations”."" = ?
What am I doing wrong that prevents active record from knowing how to
form the delete statement?
class CreatePartyAssociations < ActiveRecord::Migration
def change
create_table :party_associations, :id => false do |t|
You should not have :id false, the table needs an id column. It is
generally only when you use has_and_belongs_to_many that you do not
require an id column