Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set up dialog_field relationships through DialogFieldAssociations #15566

Merged
merged 1 commit into from
Jul 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions app/models/dialog_field.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions app/models/dialog_field_association.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class DialogFieldAssociation < ActiveRecord::Base
belongs_to :trigger, :class_name => :DialogField
belongs_to :respond, :class_name => :DialogField
end