Reputation: 1149
Given a STI parent model
class CustomForm < ApplicationRecord
has_many :templates`
end
with a couple of subclasses that should have many templates. Why would the template class below:
class FormTemplate < ApplicationRecord
belongs_to :custom_form
Why would Rails expect the FormTemplate to have a custom_form_type column defined?
All you need is the custom_form_id.
this was working before and even passes my CI but I did some other work that seems to have broken it :disappointed:
Here is the error:
PG::UndefinedColumn: ERROR: column form_templates.custom_form_type does not exist
LINE 1: ...CT “form_templates”.* FROM “form_templates”
Upvotes: 0
Views: 155
Reputation: 172
Because you didnt post all your code and the line of code caused this error. I will make a guess based on what you posted.
I think you added has_many :templates, as: :custom_form
to one of the subclass of CustomForm. It defines [Polymorphic Associations]
In the CustomForm model has_many :templates`
, it doesnt make sense to me, unless you have a templates model which is a subclass of FormTemplate
Upvotes: 1