Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #9436: reset_column_information_in_migration_fixed.diff

File reset_column_information_in_migration_fixed.diff, 1.1 kB (added by sur, 1 year ago)

patch for automated call to reset_column_information for all the loaded model classes.

  • activerecord/lib/active_record/migration.rb

    old new  
    336336        Base.logger.info "Migrating to #{migration_class} (#{migration_class.version})" 
    337337        migration_class.migrate(@direction) 
    338338        set_schema_version(migration_class.version) 
     339        ActiveRecord::Base.reset_subclasses_column_information 
    339340      end 
    340341    end 
    341342 
  • activerecord/lib/active_record/base.rb

    old new  
    288288      @@subclasses[self] << child 
    289289      super 
    290290    end 
    291      
     291 
     292    # Resets all the cached information about columns of all the subclasses. 
     293    def self.reset_subclasses_column_information 
     294      subclasses.each{|klass| klass.reset_column_information rescue nil} 
     295    end 
     296 
    292297    def self.reset_subclasses #:nodoc: 
    293298      nonreloadables = [] 
    294299      subclasses.each do |klass|