audited icon indicating copy to clipboard operation
audited copied to clipboard

Audit_comment has to be in attr_accessible

Open OAGr opened this issue 10 years ago • 2 comments

In my rails app, I declared

audited

in my user model. However, :audit_comments passed into update_attributes() wouldn't be saved. This was fixed for me by adding :audit_comments in my users attr_accessible.

I initially expected that audited handled this separate from my model, so didn't think this would be an issue. I'm not sure what the intended functionality is, but you may want to either modify the code to make using :audit_comment accessible without putting it in attr_accessible, or just modify the README to mention that it may be required.

I would be happy to add this to the README (probably in the Gotchas section) if you want.

OAGr avatar Aug 13 '14 01:08 OAGr

Hi there,

I've tested your issue using:

  • Ruby 2.3.0
  • Rails 5.0.1
  • Audited 4.7.1

And I was able to see the audited comments without adding attr_accessible.

Regards.

javiguajardo avatar Jul 07 '18 19:07 javiguajardo

I just encountered this issue in a Rails app that I'm upgrading from Rails 3.2 to Rails 4.0.

I'd say that it's likely to be caused by using the protected_attributes gem. This gem adds back the attr_accessible and attr_protected methods temporarily, and was intended as a stopgap measure for people who weren't quite ready to move to strong parameters. The gem isn't compatible with Rails 5 and up, which is probably why you haven't been able to reproduce the issue.

stevehill1981 avatar Aug 23 '19 13:08 stevehill1981