Class: Binda::Relation

Inherits:
ApplicationRecord show all
Defined in:
app/models/binda/relation.rb

Overview

Relation

This model is used to connect components and boards to each others.

Relation gathers all connection a Component record has with other records (being another Component or Board). It's possible to have multiple relations for the same component and each one can gather connections to several other components. Any relation has one owner and several dependents. A relation is a one-direction operation meaning that an owner can choose its dependents, not the other way around.

Reference: https://www.railstutorial.org/book/following_users

@example: owner = Binda::Component.first dependent = Binda::Component.last relation_setting = Binda::FieldSetting.create(field_type: relation, field_group_id: owner.structure.field_groups.first) relation = owner.relations.where(field_setting_id: relation_setting.id).first relation.dependent_components << dependent