Displaying 1 result from an estimated 1 matches for "createrelations".
Did you mean:
create_relation
2012 Mar 22
6
rescuing ActiveRecord::RecordNotUnique: clever or ugly?
I have an ActiveRecord that has several foreign keys, where the foreign
keys act as a single compound key that needs to be unique:
class CreateRelations < ActiveRecord::Migration
def change
create_table :relations do |t|
t.references :src, :null => false
t.references :dst, :null => false
end
add_index :relations, [:src_id, :dst_id], :unique => true
end
end
One obvious way to enforce uniqueness would be using...