修复:某个版本无法识别多态关联
This commit is contained in:
parent
444ce3764b
commit
f81bd6bffb
|
@ -144,7 +144,8 @@ class Api::Pm::IssuesController < Api::Pm::BaseController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
p.workbook.add_worksheet(:name => 'link_relations') do |sheet|
|
p.workbook.add_worksheet(:name => 'link_relations') do |sheet|
|
||||||
links = PmLink.joins(:linkable_issue).where(issues: {pm_project_id: params[:pm_project_id]})
|
# links = PmLink.joins(:linkable_issue).where(issues: {pm_project_id: params[:pm_project_id]})
|
||||||
|
links = PmLink.find_by_sql("SELECT `pm_links`.* FROM `pm_links` INNER JOIN `issues` ON `issues`.`id` = `pm_links`.`linkable_id` AND `pm_links`.`linkable_type` = 'Issue' WHERE `issues`.`pm_project_id` = #{params[pm_project_id]}")
|
||||||
sheet.add_row ["ID", "被关联工作项ID"]
|
sheet.add_row ["ID", "被关联工作项ID"]
|
||||||
links.each do |link|
|
links.each do |link|
|
||||||
sheet.add_row [link.linkable_id, link.be_linkable_id]
|
sheet.add_row [link.linkable_id, link.be_linkable_id]
|
||||||
|
|
|
@ -19,8 +19,8 @@
|
||||||
class PmLink < ApplicationRecord
|
class PmLink < ApplicationRecord
|
||||||
belongs_to :linkable, polymorphic: true
|
belongs_to :linkable, polymorphic: true
|
||||||
belongs_to :be_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 :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'
|
# belongs_to :be_linkable_issue, -> {where(pm_links: {be_linkable_type: 'Issue'})}, foreign_key: 'be_linkable_id', class_name: 'Issue'
|
||||||
|
|
||||||
def be_linkable
|
def be_linkable
|
||||||
be_linkable_type.constantize.find be_linkable_id
|
be_linkable_type.constantize.find be_linkable_id
|
||||||
|
|
Loading…
Reference in New Issue