instance method
attributes_from_column_definition
Ruby on Rails 3.0.20
Since v3.0.20 Last seen in v3.1.12 PrivateAvailable in: v3.0.20 v3.1.12
Signature
attributes_from_column_definition()
Initializes the attributes array with keys matching the columns from the linked table and the values matching the corresponding default value of that column, so that a new instance, or one populated from a passed-in Hash, still has all the attributes that instances loaded from the database would.
Source
# File activerecord/lib/active_record/persistence.rb, line 294
def attributes_from_column_definition
self.class.columns.inject({}) do |attributes, column|
attributes[column.name] = column.default unless column.name == self.class.primary_key
attributes
end
end
Defined in activerecord/lib/active_record/persistence.rb line 294
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::Persistence