Sha256: e4dcdab5081863d629e64d2e409ecbac6606e43c68649658b126587d17a2dd18
Contents?: true
Size: 700 Bytes
Versions: 8
Compression:
Stored size: 700 Bytes
Contents
# Since our specs are mostly about working with IDs, this module can be # included in an ActiveRecord model class to allow setting the :id attribute # on create. This is forbidden by default. # http://stackoverflow.com/questions/431617/overriding-id-on-create-in-activerecord module AllowSettingIdOnCreate module RemoveIdFromProtectedAttributes def attributes_protected_by_default super - ['id'] end end def self.included(base) if Rails.version < '3' # Rails 2 has this as an instance method base.send(:include, RemoveIdFromProtectedAttributes) else # Rails 3 has this as a class method base.send(:extend, RemoveIdFromProtectedAttributes) end end end
Version data entries
8 entries across 8 versions & 1 rubygems