Guest User

Untitled

a guest
Mar 22nd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. # Do not allow edits unless explicitly directed by `#allow_next_update!` prior to saving
  2. module Immutable
  3. extend ActiveSupport::Concern
  4.  
  5. included do
  6. before_destroy :allow_next_update!
  7. end
  8.  
  9. def allow_next_update!
  10. @allow_update = true
  11. end
  12.  
  13. def readonly?
  14. if @allow_update
  15. @allow_update = false
  16. return false
  17. end
  18.  
  19. return !new_record?
  20. end
  21. end
Add Comment
Please, Sign In to add comment