app/models/unidom/standard/standard_associating.rb in unidom-standard-1.4.1 vs app/models/unidom/standard/standard_associating.rb in unidom-standard-1.4.2
- old
+ new
@@ -6,14 +6,14 @@
self.table_name = 'unidom_standard_associatings'
include Unidom::Common::Concerns::ModelExtension
- scope :source_is, ->(source) { where source_id: (source.respond_to?(:id) ? source.id : source) }
- scope :target_is, ->(target) { where target_id: (target.respond_to?(:id) ? target.id : target) }
-
belongs_to :source, class_name: 'Unidom::Standard::Standard', foreign_key: :source_id
belongs_to :target, class_name: 'Unidom::Standard::Standard', foreign_key: :target_id
+
+ scope :source_is, ->(source) { where source_id: (source.respond_to?(:id) ? source.id : source) }
+ scope :target_is, ->(target) { where target_id: (target.respond_to?(:id) ? target.id : target) }
def self.associate!(source, with: target, due_to: 'REVS', at: Time.now)
create! source_id: to_id(source), target_id: to_id(with), association_code: due_to, opened_at: at
end