简体   繁体   中英

Multiple associations with rails Audited

I am using the Audited gem for Rails, and am using the associated audits like so:

audited allow_mass_assignment: true, associated_with: :protocol

The problem is, I need this particular model's audits to be associated with more than one models. I was hoping that something like this will work:

audited allow_mass_assignment: true, associated_with: [:protocol, :patient]

But it doesn't. It provides a clear error stating:

[:protocol, :patient] is not a symbol nor a string

The only related page I could find claims it is simply not possible, but it is quite old and I hope there is some workaround.

Any help is appreciated as always.

Not tested it but try it on seperate lines, like:

audited allow_mass_assignment: true, associated_with: :protocol
audited allow_mass_assignment: true, associated_with: :patient

For anyone searching if you can use associated_with with multiple associations, currently that is not possible .

Although, someone submitted a PR , it did not work as expected.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM