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

Ticket #9775: foreign_key_on_migrations.patch

File foreign_key_on_migrations.patch, 0.8 kB (added by arthurgeek, 1 year ago)
  • lib/active_record/connection_adapters/abstract/schema_definitions.rb

    old new  
    376376        column(:created_at, :datetime) 
    377377        column(:updated_at, :datetime) 
    378378      end 
     379       
     380      def foreign_key(*args) 
     381        options = args.last.is_a?(Hash) ? args.pop : {} 
     382        args.each do |col|  
     383          column(id = "#{col}_id", :integer, options) 
     384        end  
     385      end 
     386      alias :fkey :foreign_key 
    379387 
    380388      # Returns a String whose contents are the column definitions 
    381389      # concatenated together.  This string can then be pre and appended to