You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class Part
multisearchable against: %i[name description part_number_formatted]
has_one :part_number
delegate :formatted, to: :part_number, prefix: true
class PartNumber
belongs_to :part, touch: true
This seems to be the approach recommended by this stackoverflow post for searching attributes across associations.
class PartNumber
after_destroy :reset_part_association
after_create :reset_part_association
def reset_part_association
part&.association(:part_number)&.reset
end
The changes to PartNumber were necessary so that when part.part_number.destroy is called, part.part_number is reloaded and the pg_search_document content stops including the formatted part number.
The text was updated successfully, but these errors were encountered:
I have the following models:
This seems to be the approach recommended by this stackoverflow post for searching attributes across associations.
#157 is similar, but I'm observing a different problem: Since
update_pg_search_documents
is called onlyafter_save
, the pg_search_document content is not updated when the part number is updated, even withtouch: true
.My workaround was:
The changes to PartNumber were necessary so that when
part.part_number.destroy
is called,part.part_number
is reloaded and the pg_search_document content stops including the formatted part number.The text was updated successfully, but these errors were encountered: