Title / Description
Code require 'rubygems' require 'activerecord' require 'pp' ActiveRecord::Base.establish_connection :adapter => 'postgresql', :database => 'ferry', :username => 'grust', :password => '...', :port => 5432, :host => 'localhost', :allow_concurrency => true ActiveRecord::Base.logger = Logger.new(STDOUT) class Department < ActiveRecord::Base has_many :employees, :foreign_key => :dept end class Employee < ActiveRecord::Base belongs_to :department, :foreign_key => :dept end e = [] Department.find(:all).each { |d| pp d.employees } Department.find(:all, :include => :employees).each { |d| pp d.employees }
Author
Highlight as C C++ CSS Clojure Delphi ERb Groovy (beta) HAML HTML JSON Java JavaScript PHP Plain text Python Ruby SQL XML YAML diff code