Z Devel


210 Experience
2 Lessons Completed
0 Questions Solved


I'm building my own soft deletable module, but I would like to set the current_user.id in a deleted_by column, to know which user deleted it. It is bad practice to set the user as a global variable available to the model layer due to thread safety...see thread_mattr_accessor and thread_cattr_accessor and a nice article by BigBinary. I will simply implement a destroy(user_id=0) method. If the user_id is passed through from the controller, it will be saved...otherwise the deleter will be 0 and therefore unknown.

logo Created with Sketch.

Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

© 2020 GoRails, LLC. All rights reserved.