Skip to content

Disable create audits on child record #758

@geronimogarcialumint

Description

@geronimogarcialumint

I've extended audited on my ApplicationRecord model, but I have a couple of classes that I'd like to only do %i[update destroy] audits, instead of the %i[create update destroy] defined over application_record.rb

I've added audited on: %i[update destroy] to the child model. Doing ChildClass.audited_options correctly returns {:on=>[:update, :destroy], :only=>[], :except=>[], :max_audits=>nil}

Issue is that whenever I do ChildClass.create() I get a created audit associated to the record, even if the audited_options for the class doesn't show :create on the :on option.

Not sure if relevant, but also Audited::Audit.audited_classes only returns [ApplicationRecord(abstract)]

If I make ChildClass not inherit from ApplicationRecord, I see it being listed on audited_classes and it works as expected (no audit created on create action)

Am I doing something wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions