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
require 'active_record' | |
require 'mysql2' | |
require 'minitest/autorun' | |
require 'logger' | |
puts "ActiveRecord: #{ActiveRecord::VERSION::STRING}" | |
ActiveRecord::Base.establish_connection(adapter: "mysql2", host: "localhost", database: "test") | |
ActiveRecord::Base.logger = Logger.new(STDOUT) | |
class Author < ActiveRecord::Base |
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
require 'active_record' | |
require 'minitest/autorun' | |
require 'logger' | |
puts "ActiveRecord: #{ActiveRecord::VERSION::STRING}" | |
case ARGV[0] | |
when 'pg' | |
require 'pg' | |
ActiveRecord::Base.establish_connection(adapter: "postgresql", host: "localhost", user: "postgres", database: "test") | |
when 'mysql' |
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
require 'mongoid' | |
require 'mongoid/support/query_counter' | |
Mongoid.configure.connect_to("mongoid_test") | |
logger = Logger.new $stdout | |
logger.level = 0 | |
class Post | |
include Mongoid::Document | |
belongs_to :person | |
end |
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
require 'active_record' | |
require 'minitest/autorun' | |
require 'logger' | |
# This connection will do for database-independent bug reports. | |
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:') | |
ActiveRecord::Base.logger = Logger.new(STDOUT) | |
p ActiveRecord.version | |
class Foo < ActiveRecord::Base |
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
require 'sprockets/rails/task' | |
Rake::Task["assets:environment"].clear | |
Rake::Task["assets:precompile"].clear | |
Rake::Task["assets:clean"].clear | |
Rake::Task["assets:clobber"].clear | |
Sprockets::Rails::Task.new(Rails.application) do |t| | |
t.manifest = lambda do | |
app = Rails.application | |
Sprockets::Manifest.new(app.assets, File.join(app.root, 'public', app.config.assets.prefix, 'manifest.json')) |
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
require 'benchmark' | |
arr = (1..100).to_a | |
Benchmark.bm(20) do |x| | |
x.report("each.with_index") do | |
100_000.times do | |
arr.each_with_index do |v, i| | |
end |
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
require 'active_record' | |
require 'benchmark' | |
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:') | |
ActiveRecord::Schema.define do | |
create_table :posts, force: true do |t| | |
t.integer :comments_count | |
end | |
create_table :comments, force: true do |t| |
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
require 'active_record' | |
require 'benchmark' | |
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:') | |
ActiveRecord::Schema.define do | |
create_table :posts, force: true do |t| | |
t.integer :comments_count | |
end |
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
require 'active_record' | |
require 'benchmark' | |
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:') | |
ActiveRecord::Schema.define do | |
create_table :posts, force: true do |t| | |
t.integer :comments_count | |
end |
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
require 'active_record' | |
require 'benchmark' | |
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:') | |
ActiveRecord::Schema.define do | |
create_table :posts, force: true do |t| | |
t.integer :comments_count | |
end |
OlderNewer