Mysql::Error: Duplicate entry
- by Shaliko
Hi
I have a model
class Gift < ActiveRecord::Base
validates_uniqueness_of :giver_id, :scope => :account_id
end
add_index(:gifts, [:account_id, :giver_id], :uniq => true)
Action
def create
@gift= Gift.new(params[:gift])
if @gift.save
...
else
...
end
end
In the "production" mode, I sometimes get an error
ActiveRecord::StatementInvalid: Mysql::Error: Duplicate entry '122394471958-50301499' for key 'index_gifts_on_account_id_and_user_id'
What the problem?