house9 / clerk

Clerk adds the following attributes to your ActiveRecord objects [creator, updater] and will automatically update these attributes using before_create and before_update ActiveRecord callback methods
MIT License
26 stars 5 forks source link

Issue when using devise/activeadmin #3

Open fokcep opened 11 years ago

fokcep commented 11 years ago

Looks like there is threading issue in your gem. When I use it with activeadmin on login - a user being updated (with ip address, timestamp) but creator/updater are set to a wrong user. Probably the last user used by the system? And on some logins it doesn't update to any user - i.e. user not yet available in the filter chain?

Any ideas?

house9 commented 11 years ago

this gem uses sentient_user see https://github.com/bokmann/sentient_user/blob/master/lib/sentient_user.rb which is using Thread.current - i have encountered similar issues that you describe.

I've been using a System Account user and setting that as the default if the logged on user cannot be determined, but i think with devise when the user is authenticating they are not actually logged on until after their attributes (ip, etc) are updated; you might not be able to set the System Account without overriding the devise controller before the authentication occurs

fokcep commented 11 years ago

thanks for the tip, I will check the devise controller and see if it can be fixed there

SaraswatiSaud commented 6 years ago

I got a similar issue with RailsAdmin, where an admin user when updates the record, the updated_by_id field is not updated. When I try from the console, it is updated as needed.