Class: ActiveRecord::ConnectionAdapters::TableDefinition
- Inherits:
-
Object
- Object
- ActiveRecord::ConnectionAdapters::TableDefinition
- Defined in:
- lib/generators/mysql/search/templates/config/initializers/active_record_ext.rb
Overview
Overrides the timestamps method in TableDefinition to use MySQL's DATETIME ON UPDATE CURRENT_TIMESTAMP
for the updated_at column.
This allows the updated_at column to automatically update its value whenever the row is updated.
Instance Method Summary collapse
Instance Method Details
#timestamps(**options) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/generators/mysql/search/templates/config/initializers/active_record_ext.rb', line 23 def (**) [:null] = false if [:null].nil? [:precision] = 6 if !.key?(:precision) && @conn.supports_datetime_with_precision? column(:created_at, :datetime, **) column(:updated_at, 'DATETIME ON UPDATE CURRENT_TIMESTAMP', **) end |