Skip to content

Instantly share code, notes, and snippets.

@akishin
Created July 17, 2013 12:46
Show Gist options
  • Save akishin/6020251 to your computer and use it in GitHub Desktop.
Save akishin/6020251 to your computer and use it in GitHub Desktop.
ActiveRecord read only model
module Readonlyable
extend ActiveSupport::Concern
def readonly?
return true
end
def before_destroy
raise ActiveRecord::ReadOnlyRecord
end
module ClassMethods
def delete(id)
raise ActiveRecord::ReadOnlyRecord
end
def delete_all(conditions)
raise ActiveRecord::ReadOnlyRecord
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment