class Foo
has_many :foo_bars
audited
has_associated_audits
end
class Bar
has_many :foo_bars
audited
has_associated_audits
end
class FooBar
self.primary_key = [:foo_id, :bar_id] # i.e., there is no "id" column
belongs_to :foo
belongs_to :bar
audited associated_with: :foo
audited associated_with: :bar
end
Currently it would give an error similar to this:
ActiveRecord::CompositePrimaryKeyMismatchError:
Association FoobBar#audits primary key ["foo_id", "bar_id"] doesn't match with foreign key auditable_id. Please specify query_constraints, or primary_key and foreign_key values.
I think that'd be a great addition, but I don't personally have any projects with composite primary keys, so my motivation to add this is low. I'd gladly review a PR.
Can
audited
support the following scenario using Rails 7.1's composite primary keys?Currently it would give an error similar to this: