Skip to content

Instantly share code, notes, and snippets.

@jonleighton
Created September 28, 2011 17:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonleighton/1248588 to your computer and use it in GitHub Desktop.
Save jonleighton/1248588 to your computer and use it in GitHub Desktop.
$ ruby ~/Desktop/test.rb
Active Record 3.0.10
-- create_table(:foos)
-> 0.6120s
-- create_table(:bars)
-> 0.0008s
size: 0
count: 0
length: 0
$ ruby ~/Desktop/test.rb
Active Record 3.1.0
-- create_table(:foos)
-> 0.0356s
-- create_table(:bars)
-> 0.0008s
size: 1
count: 0
length: 1
gem 'rails', '3.0.0'
# gem 'rails', '3.1.0'
require 'active_record'
puts "Active Record #{ActiveRecord::VERSION::STRING}"
ActiveRecord::Base.establish_connection(
:adapter => 'sqlite3',
:database => ':memory:'
)
ActiveRecord::Schema.define do
create_table :foos
create_table :bars do |t|
t.integer :foo_id
end
end
class Foo < ActiveRecord::Base
has_many :bars
end
class Bar < ActiveRecord::Base
end
foo = Foo.create!
foo.bars.new
puts "size: #{foo.bars.size}"
puts "count: #{foo.bars.count}"
puts "length: #{foo.bars.length}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment