Closed llpereiras closed 3 months ago
This fix isnt correct. But this does look like it would be an issue for polymorphic relationships.
Seems like it should be something like the following:
if assoc.options[:polymorphic]
assoc_record = @record.send(assoc.name)
if assoc_record && ::PaperTrail.request.enabled_for_model?(assoc.class)
assoc_version_args[:foreign_key_id] = @record.send(assoc.foreign_key)
assoc_version_args[:foreign_type] = assoc_record.class.name
end
It seems like we are missing specs for this in https://github.com/westonganger/paper_trail-association_tracking/blob/master/spec/paper_trail/associations/belongs_to_spec.rb
@westonganger Thanks for your reply, I will check your suggestion on the next week and try add specs too.
Duplicate of https://github.com/westonganger/paper_trail-association_tracking/pull/48 which has already been merged
Hi guys, on this week, we upgrade version of rails to 7.0 in big legacy project on our company. Another upgrade was paper_trail to version 14. After upgrade this problem start happen.
The variable
foreign_type
started to resolve to string empty""
In the next line
if foreign_type && ::PaperTrail.request.enabled_for_model?(foreign_type.constantize)
We get the this error:wrong constant name \n\n Object.const_get(camel_cased_word)
The backtrace of paper_trail:
We add
.presence
method to fix this problem.It's make senses?