Validation for boolean on has_many relation

I’ve 2 models :
model_A hasMany model_B on model_B I’ve an attribute called default_element (true/false)
how can I guarantee that I only have one and at most one on the connected elements with attribute=true and other false?

…should I refer to a custom validator ? Any example ? Tnx

Hi @paskuale,

Check this section of the guide:

Guide > ActiveRecord > Dynamic Relational Query

I’m sorry. I’ve failed to understand your question. The answer above is irrelevant to the issue.

I’ve no idea at the moment.

no problem we would miss, thanks anyway :wink: