Det ser ut som att din gifts-tabell har ett unikt index som spänner över account_id och user_id. Om du vill behålla det indexet, lägg till en matchande unikahetsvalidering till din modell:
class Gift < ActiveRecord::Base validates_uniqueness_of :giver_id, :scope => :account_id validates_uniqueness_of :user_id, :scope => :account_id end Annars, ta bort indexet:
DROP INDEX index_gifts_on_account_id_and_user_id ON gifts Redigering: Du kan också vilja lägga till en närvarokontroll för giver_id:
class Gift < ActiveRecord::Base validates_presence_of :giver_id validates_uniqueness_of :user_id, :scope => :account_id end