In a migration:
add_index :cats, [:place_id, :tray_id], unique: true
In the model as a validation:
validates :tray, uniqueness: {scope: :place}
Feb 14, 2025
In a migration:
add_index :cats, [:place_id, :tray_id], unique: true
In the model as a validation:
validates :tray, uniqueness: {scope: :place}