diff options
author | Hongli Lai (Phusion) <hongli@phusion.nl> | 2008-09-17 02:53:39 +0200 |
---|---|---|
committer | Hongli Lai (Phusion) <hongli@phusion.nl> | 2008-09-17 02:54:22 +0200 |
commit | 6941c98ec93a0f7427e54c40ce3a3309d04d61ca (patch) | |
tree | d9a86f1f4c00345959b2fcac5b8585a0620eee2d | |
parent | 606b62af5d4ac8aa3a38266e9053767ed452bc5f (diff) | |
download | rails-6941c98ec93a0f7427e54c40ce3a3309d04d61ca.tar.gz rails-6941c98ec93a0f7427e54c40ce3a3309d04d61ca.tar.bz2 rails-6941c98ec93a0f7427e54c40ce3a3309d04d61ca.zip |
Improve documentation for ActiveRecord::Base#reset_column_information
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 91b69747e0..a925ba6e20 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -1221,7 +1221,32 @@ module ActiveRecord #:nodoc: end end - # Resets all the cached information about columns, which will cause them to be reloaded on the next request. + # 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 def reset_column_information generated_methods.each { |name| undef_method(name) } @column_names = @columns = @columns_hash = @content_columns = @dynamic_methods_hash = @generated_methods = @inheritance_column = nil |