Module ActiveRecord::Acts::Versioned::ActMethods::ClassMethods
In: lib/acts_as_versioned.rb

Methods

Public Instance methods

Rake migration task to create the versioned table using options passed to acts_as_versioned

[Source]

     # File lib/acts_as_versioned.rb, line 332
332:           def create_versioned_table(create_table_options = {})
333:             self.transaction do
334:               # create version column in main table if it does not exist
335:               if !self.content_columns.find { |c| %w(version lock_version).include? c.name }
336:                 self.connection.add_column table_name, :version, :integer
337:               end
338:               
339:               self.connection.create_table(versioned_table_name, create_table_options) do |t|
340:                 t.column versioned_foreign_key, :integer
341:                 t.column :version, :integer
342:               end
343:               
344:               updated_col = nil
345:               self.versioned_columns.each do |col| 
346:                 updated_col = col if !updated_col and %(updated_at updated_on).include?(col.name)
347:                 self.connection.add_column versioned_table_name, col.name, col.type, 
348:                   :limit => col.limit, 
349:                   :default => col.default
350:               end
351:           
352:               if type_col = self.columns_hash[inheritance_column]
353:                 self.connection.add_column versioned_table_name, versioned_inheritance_column, type_col.type, 
354:                   :limit => type_col.limit, 
355:                   :default => type_col.default
356:               end
357:       
358:               if updated_col.nil?
359:                 self.connection.add_column versioned_table_name, :updated_at, :timestamp
360:               end
361:             end
362:           end

Rake migration task to drop the versioned table

[Source]

     # File lib/acts_as_versioned.rb, line 365
365:           def drop_versioned_table
366:             self.connection.drop_table versioned_table_name
367:           end

An array of fields that are not saved in the versioned table

[Source]

     # File lib/acts_as_versioned.rb, line 327
327:           def non_versioned_fields
328:             [self.primary_key, inheritance_column, 'version', 'lock_version', versioned_inheritance_column]
329:           end

Returns an instance of the dynamic versioned model

[Source]

     # File lib/acts_as_versioned.rb, line 322
322:           def versioned_class
323:             "ActiveRecord::Acts::Versioned::#{versioned_class_name}".constantize
324:           end

Returns an array of columns that are versioned. See non_versioned_fields

[Source]

     # File lib/acts_as_versioned.rb, line 317
317:           def versioned_columns
318:             self.columns.select { |c| !non_versioned_fields.include?(c.name) }
319:           end

[Validate]