Created
September 28, 2011 17:31
-
-
Save jonleighton/1248588 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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