Is there an easy way to make a Rails ActiveRecord model read-only?

Looking at ActiveRecord::Persistence, everything ends up calling create_or_update behind the scenes.

def create_or_update
  raise ReadOnlyRecord if readonly?
  result = new_record? ? create : update
  result != false
end

So! Just:

def readonly?
  !new_record?
end

Leave a Comment