class method
self.reset_column_information
Ruby on Rails 3.0.20
Since v2.2.3 Last seen in v3.1.12Signature
self.reset_column_information()
Resets all the cached information about columns, which will cause them to be reloaded on the next request.
The most common usage pattern for this method is probably in a migration, when just after creating a table you want to populate it with some default values, eg:
class CreateJobLevels < ActiveRecord::Migration def self.up create_table :job_levels do |t| t.integer :id t.string :name t.timestamps end JobLevel.reset_column_information %w{assistant executive manager director}.each do |type| JobLevel.create(:name => type) end end def self.down drop_table :job_levels end end
Source
# File activerecord/lib/active_record/base.rb, line 747
def reset_column_information
undefine_attribute_methods
@column_names = @columns = @columns_hash = @content_columns = @dynamic_methods_hash = @inheritance_column = nil
@arel_engine = @relation = @arel_table = nil
end
Defined in activerecord/lib/active_record/base.rb line 747
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::Base