forgeplus/app/models/pm_link.rb

29 lines
979 B
Ruby

# == Schema Information
#
# Table name: pm_links
#
# id :integer not null, primary key
# be_linkable_type :string(255) not null
# be_linkable_id :integer not null
# linkable_type :string(255) not null
# linkable_id :integer not null
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_pm_links_on_linkable_id (linkable_id)
# index_pm_links_on_linkable_type (linkable_type)
#
class PmLink < ApplicationRecord
belongs_to :linkable, polymorphic: true
belongs_to :be_linkable, polymorphic: true
# belongs_to :linkable_issue, -> {where(pm_links: {linkable_type: 'Issue'})}, foreign_key: 'linkable_id', class_name: 'Issue'
# belongs_to :be_linkable_issue, -> {where(pm_links: {be_linkable_type: 'Issue'})}, foreign_key: 'be_linkable_id', class_name: 'Issue'
def be_linkable
be_linkable_type.constantize.find be_linkable_id
end
end