associations - check satisfiability of a constraint when using rails shovel operator -
In my rail application, I have a group class in which there are many relationships related to the question "subgroup is going to happen."
I am using shovel operator group group (sub group ) As a specific group X. The hindrance in this question is that we should not make any circle when adding the subgroup, that is, I have to ensure that none of the new members is already in the ancestor of Group X.
A simple answer is to write a custom method to do this, which is definitely possible, but I want to know whether it is possible to use this False Operator and not a custom function of my own. is.
I think it is not possible to get this behavior done with a shovel operator. The good news is that the union "duck" like an array, you can use the union operator with array
for converting input, for example
and gt; Group_a, group_b = Group.new, Group.new & gt; Group_a.subgroups | = Array (group_b)