I have a Remediation model which inherits from AssessmentHighRiskFactor model and added some custom show fields from other tables using relationships. The fields are visible and working fine, but I can't use the filter by 'cycle' in the admin panel (throws errors).
- It is trying to access the cycle column which belongs to (
institution_company_topicstable) in theassessment_high_risk_factortable. - PG::UndefinedTable: ERROR: missing FROM-clause entry for table
assessmentsorinstitution_company_topics - Unknown column (because it is not doing the filter in the corresponding table)
Remediation model:
class Remediation < AssessmentHighRiskFactor
has_one :company, through: :assessment
has_one :institution_company_topic, through: :assessment
def cycle
institution_company_topic&.cycle
end
rails_admin do
def helper_text
'Manage Remediation'
end
list do
field :cycle do
queryable true
searchable true
filterable true
end
end
end
- Already tried with scopes (with custom query to join tables)
- Using bindings objects
- Using
searchable [{InstitutionCompanyTopic => :cycle}]or[:cycle]
AssessmentHighRiskFactor model:
class AssessmentHighRiskFactor < ApplicationRecord
belongs_to :assessment
end
Assessment model:
class Assessment < ApplicationRecord
belongs_to :institution_company_topic, optional: true
has_many :assessment_high_risk_factors, dependent: :destroy
end
InstitutionCompanyTopic model:
class InstitutionCompanyTopic < ApplicationRecord
has_many :assessments, dependent: :destroy
end
gem 'rails_admin', '~> 2.1.0'
Any ideas would be good.