Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Do not allow edits unless explicitly directed by `#allow_next_update!` prior to saving
- module Immutable
- extend ActiveSupport::Concern
- included do
- before_destroy :allow_next_update!
- end
- def allow_next_update!
- @allow_update = true
- end
- def readonly?
- if @allow_update
- @allow_update = false
- return false
- end
- return !new_record?
- end
- end
Add Comment
Please, Sign In to add comment