diff --git a/app/models/dialog_field.rb b/app/models/dialog_field.rb index 58bc939186b..3381c0eda5d 100644 --- a/app/models/dialog_field.rb +++ b/app/models/dialog_field.rb @@ -6,6 +6,22 @@ class DialogField < ApplicationRecord belongs_to :dialog_group has_one :resource_action, :as => :resource, :dependent => :destroy + has_many :dialog_field_associations, + :foreign_key => :trigger_id, + :class_name => :DialogFieldAssociation, + :dependent => :destroy + has_many :reverse_dialog_field_associations, + :foreign_key => :respond_id, + :class_name => :DialogFieldAssociation, + :dependent => :destroy + + has_many :dialog_field_responders, + :source => :respond, + :through => :dialog_field_associations + has_many :dialog_field_triggers, + :source => :trigger, + :through => :reverse_dialog_field_associations + alias_attribute :order, :position validates_presence_of :name diff --git a/app/models/dialog_field_association.rb b/app/models/dialog_field_association.rb new file mode 100644 index 00000000000..0f5e509b80d --- /dev/null +++ b/app/models/dialog_field_association.rb @@ -0,0 +1,4 @@ +class DialogFieldAssociation < ActiveRecord::Base + belongs_to :trigger, :class_name => :DialogField + belongs_to :respond, :class_name => :DialogField +end