Validation for boolean on has_many relation

(Pellicanipasquale) #1

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?

(Pellicanipasquale) #2

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

(Softark) #3

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.

(Pellicanipasquale) #4

no problem we would miss, thanks anyway :wink: