Activerecord - Dealing With Table Contraint Violations

Hi folks,

In my CRUD for a table in my DB, I have the PK and another 3 fields, with the other 3 fields being indexed and constrained to be unique. If I violate the constraint during create or update, I get a ghastly system error starting the constraint violation. Is there any way to deal with this in a more discrete manner?

Well, there’s always the unique validator. If you used gii for code generation, it should have applied that validator in the first place …

Ah, nice one. I am still learning slowly but surely :)

Does Gii apply this to compound indexes defined in SQL (prior to model generation, of course) or only to single-field indexes? I ask as it does not seem to have generated it for the (many) tables I created with compound unique indexes.

I’m not quite sure. gii has its issues with composite indices. You might give giix a try.