Sha256: a23a3194abddef21c898f77535b5a52a8e51ce96dac5b4dc00f45cb22aea43ba
Contents?: true
Size: 1.17 KB
Versions: 6
Compression:
Stored size: 1.17 KB
Contents
# --- Test data model setup --- RubyVM::YJIT.enable if ENV["YJIT"] require "csv" require "pg" require "active_record" require "active_record/connection_adapters/postgresql_adapter" require "logger" require "oj" require "sqlite3" Oj.optimize_rails unless ENV['NO_OJ_OPTIMIZE_RAILS'] ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:") # ActiveRecord::Base.logger = Logger.new($stdout) ActiveRecord::Schema.define do create_table :posts, force: true do |t| t.string :body end create_table :comments, force: true do |t| t.integer :post_id t.string :body t.integer :commenter_id end create_table :users, force: true do |t| t.string :name end end class Post < ActiveRecord::Base has_many :comments has_many :commenters, through: :comments, class_name: 'User', source: :commenter def attributes {id: nil, body: nil, commenter_names: commenter_names} end def commenter_names commenters.pluck(:name) end end class Comment < ActiveRecord::Base belongs_to :post belongs_to :commenter, class_name: 'User' def attributes {id: nil, body: nil} end end class User < ActiveRecord::Base has_many :comments end
Version data entries
6 entries across 6 versions & 1 rubygems
Version | Path |
---|---|
alba-3.5.0 | benchmark/prep.rb |
alba-3.4.0 | benchmark/prep.rb |
alba-3.3.3 | benchmark/prep.rb |
alba-3.3.2 | benchmark/prep.rb |
alba-3.3.1 | benchmark/prep.rb |
alba-3.3.0 | benchmark/prep.rb |