repo stringlengths 5 92 | file_url stringlengths 80 287 | file_path stringlengths 5 197 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:37:27 2026-01-04 17:58:21 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/company_in_module.rb | activerecord/test/models/company_in_module.rb | # frozen_string_literal: true
require "active_support/core_ext/object/with_options"
module MyApplication
module Business
class Company < ActiveRecord::Base
end
class Firm < Company
has_many :clients, -> { order("id") }, dependent: :destroy
has_many :clients_sorted_desc, -> { order("id DESC"... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/aircraft.rb | activerecord/test/models/aircraft.rb | # frozen_string_literal: true
class Aircraft < ActiveRecord::Base
self.pluralize_table_names = false
has_many :engines, foreign_key: "car_id"
has_many :wheels, as: :wheelable
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/uuid_entry.rb | activerecord/test/models/uuid_entry.rb | # frozen_string_literal: true
class UuidEntry < ActiveRecord::Base
delegated_type :entryable, types: %w[ UuidMessage UuidComment ], primary_key: :uuid, foreign_key: :entryable_uuid
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/rating.rb | activerecord/test/models/rating.rb | # frozen_string_literal: true
class Rating < ActiveRecord::Base
belongs_to :comment
has_many :taggings, as: :taggable
has_many :taggings_without_tag, -> { left_joins(:tag).where("tags.id": [nil, 0]) }, as: :taggable, class_name: "Tagging"
has_many :taggings_with_no_tag, -> { joins("LEFT OUTER JOIN tags ON tags... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/dl_keyed_belongs_to.rb | activerecord/test/models/dl_keyed_belongs_to.rb | # frozen_string_literal: true
class DlKeyedBelongsTo < ActiveRecord::Base
self.primary_key = "belongs_key"
belongs_to :destroy_async_parent,
dependent: :destroy_async,
foreign_key: :destroy_async_parent_id,
primary_key: :parent_id,
class_name: "DestroyAsyncParent"
belongs_to :destroy_async_parent... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/post.rb | activerecord/test/models/post.rb | # frozen_string_literal: true
require "models/tag"
require "models/tagging"
require "models/comment"
require "models/category"
class Post < ActiveRecord::Base
class CategoryPost < ActiveRecord::Base
self.table_name = "categories_posts"
belongs_to :group, foreign_key: :category_id, class_name: "Category"
... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/subscriber.rb | activerecord/test/models/subscriber.rb | # frozen_string_literal: true
class Subscriber < ActiveRecord::Base
self.primary_key = "nick"
has_many :subscriptions
has_many :books, through: :subscriptions
end
class SpecialSubscriber < Subscriber
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/car.rb | activerecord/test/models/car.rb | # frozen_string_literal: true
class Car < ActiveRecord::Base
belongs_to :person, counter_cache: true
has_many :bulbs
has_many :all_bulbs, -> { unscope(where: :name) }, class_name: "Bulb"
has_many :all_bulbs2, -> { unscope(:where) }, class_name: "Bulb"
has_many :other_bulbs, -> { unscope(where: :name).where(n... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/family_tree.rb | activerecord/test/models/family_tree.rb | # frozen_string_literal: true
class FamilyTree < ActiveRecord::Base
belongs_to :member, class_name: "User", foreign_key: "member_id"
belongs_to :family
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/organization.rb | activerecord/test/models/organization.rb | # frozen_string_literal: true
class Organization < ActiveRecord::Base
has_many :member_details
has_many :members, through: :member_details
has_many :authors, primary_key: :name
has_many :author_essay_categories, through: :authors, source: :essay_categories
has_one :author, primary_key: :name
has_one :aut... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/electron.rb | activerecord/test/models/electron.rb | # frozen_string_literal: true
class Electron < ActiveRecord::Base
belongs_to :molecule
validates_presence_of :name
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/shipping_line.rb | activerecord/test/models/shipping_line.rb | # frozen_string_literal: true
class ShippingLine < ActiveRecord::Base
belongs_to :invoice, touch: true
has_many :discount_applications, class_name: "ShippingLineDiscountApplication"
end
class ShippingLineDiscountApplication < ActiveRecord::Base
belongs_to :shipping_line
belongs_to :discount
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/essay_destroy_async.rb | activerecord/test/models/essay_destroy_async.rb | # frozen_string_literal: true
class EssayDestroyAsync < ActiveRecord::Base
self.table_name = "essays"
belongs_to :book, dependent: :destroy_async, class_name: "BookDestroyAsync"
belongs_to :writer, polymorphic: true, dependent: :destroy_async
end
class LongEssayDestroyAsync < EssayDestroyAsync
end
class ShortE... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/dog.rb | activerecord/test/models/dog.rb | # frozen_string_literal: true
class Dog < ActiveRecord::Base
belongs_to :breeder, class_name: "DogLover", counter_cache: :bred_dogs_count
belongs_to :trainer, class_name: "DogLover", counter_cache: :trained_dogs_count
belongs_to :doglover, foreign_key: :dog_lover_id, class_name: "DogLover", counter_cache: true
e... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/editor.rb | activerecord/test/models/editor.rb | # frozen_string_literal: true
class Editor < ActiveRecord::Base
self.primary_key = "name"
has_one :publication, foreign_key: :editor_in_chief_id, inverse_of: :editor_in_chief
has_many :editorships
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/guitar.rb | activerecord/test/models/guitar.rb | # frozen_string_literal: true
class Guitar < ActiveRecord::Base
has_many :tuning_pegs, index_errors: true
accepts_nested_attributes_for :tuning_pegs
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/mentor.rb | activerecord/test/models/mentor.rb | # frozen_string_literal: true
class Mentor < ActiveRecord::Base
has_many :developers
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/post_encrypted.rb | activerecord/test/models/post_encrypted.rb | # frozen_string_literal: true
require "models/post"
class EncryptedPost < Post
self.table_name = "posts"
# We want to modify the key for testing purposes
class MutableDerivedSecretKeyProvider < ActiveRecord::Encryption::DerivedSecretKeyProvider
attr_accessor :keys
end
encrypts :title
encrypts :body,... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/invoice.rb | activerecord/test/models/invoice.rb | # frozen_string_literal: true
class Invoice < ActiveRecord::Base
has_many :line_items, autosave: true
has_many :shipping_lines, -> { from("shipping_lines") }, autosave: true
before_save { |record| record.balance = record.line_items.map(&:amount).compact.sum }
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/possession.rb | activerecord/test/models/possession.rb | # frozen_string_literal: true
class Possession < ActiveRecord::Base
self.table_name = "having"
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/joke.rb | activerecord/test/models/joke.rb | # frozen_string_literal: true
class Joke < ActiveRecord::Base
self.table_name = "funny_jokes"
end
class GoodJoke < ActiveRecord::Base
self.table_name = "funny_jokes"
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/non_primary_key.rb | activerecord/test/models/non_primary_key.rb | # frozen_string_literal: true
class NonPrimaryKey < ActiveRecord::Base
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/minimalistic.rb | activerecord/test/models/minimalistic.rb | # frozen_string_literal: true
class Minimalistic < ActiveRecord::Base
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/friendship.rb | activerecord/test/models/friendship.rb | # frozen_string_literal: true
class Friendship < ActiveRecord::Base
belongs_to :friend, class_name: "Person"
# friend_too exists to test a bug, and probably shouldn't be used elsewhere
belongs_to :friend_too, foreign_key: "friend_id", class_name: "Person", counter_cache: :friends_too_count
belongs_to :follower... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/toy.rb | activerecord/test/models/toy.rb | # frozen_string_literal: true
class Toy < ActiveRecord::Base
self.primary_key = :toy_id
belongs_to :pet
has_many :sponsors, as: :sponsorable, inverse_of: :sponsorable
scope :with_pet, -> { joins(:pet) }
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/pirate.rb | activerecord/test/models/pirate.rb | # frozen_string_literal: true
class Pirate < ActiveRecord::Base
belongs_to :parrot, validate: true
belongs_to :non_validated_parrot, class_name: "Parrot"
has_and_belongs_to_many :parrots, -> { order("parrots.id ASC") }, validate: true
has_and_belongs_to_many :non_validated_parrots, class_name: "Parrot"
has_a... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/tagging.rb | activerecord/test/models/tagging.rb | # frozen_string_literal: true
# test that attr_readonly isn't called on the :taggable polymorphic association
module Taggable
end
class Tagging < ActiveRecord::Base
belongs_to :tag, -> { includes(:tagging) }
belongs_to :super_tag, class_name: "Tag", foreign_key: "super_tag_id"
belongs_to :invalid_tag, class_n... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/author_encrypted.rb | activerecord/test/models/author_encrypted.rb | # frozen_string_literal: true
require "models/author"
class EncryptedAuthor < Author
self.table_name = "authors"
validates :name, uniqueness: true
encrypts :name, previous: { deterministic: true }
end
class EncryptedAuthorWithKey < Author
self.table_name = "authors"
encrypts :name, key: "some secret key!... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/dl_keyed_belongs_to_soft_delete.rb | activerecord/test/models/dl_keyed_belongs_to_soft_delete.rb | # frozen_string_literal: true
require "models/destroy_async_parent_soft_delete"
class DlKeyedBelongsToSoftDelete < ActiveRecord::Base
belongs_to :destroy_async_parent_soft_delete,
dependent: :destroy_async,
ensuring_owner_was: :deleted?,
class_name: "DestroyAsyncParentSoftDelete"
def deleted?
del... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/edge.rb | activerecord/test/models/edge.rb | # frozen_string_literal: true
# This class models an edge in a directed graph.
class Edge < ActiveRecord::Base
belongs_to :source, class_name: "Vertex", foreign_key: "source_id"
belongs_to :sink, class_name: "Vertex", foreign_key: "sink_id"
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/sharded.rb | activerecord/test/models/sharded.rb | # frozen_string_literal: true
require_relative "sharded/blog"
require_relative "sharded/blog_post"
require_relative "sharded/blog_post_with_revision"
require_relative "sharded/comment"
require_relative "sharded/tag"
require_relative "sharded/blog_post_tag"
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/eye.rb | activerecord/test/models/eye.rb | # frozen_string_literal: true
class Eye < ActiveRecord::Base
attr_reader :after_create_callbacks_stack
attr_reader :after_update_callbacks_stack
attr_reader :after_save_callbacks_stack
attr_writer :override_iris_with_read_only_foreign_key_color
# Callbacks configured before the ones has_one sets up.
after... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/interest.rb | activerecord/test/models/interest.rb | # frozen_string_literal: true
class Interest < ActiveRecord::Base
belongs_to :human, inverse_of: :interests
belongs_to :human_with_callbacks,
class_name: "Human",
foreign_key: :human_id,
inverse_of: :interests_with_callbacks
belongs_to :polymorphic_human, polymorphic: true, inverse_of: :polymorphic_i... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/shop.rb | activerecord/test/models/shop.rb | # frozen_string_literal: true
module Shop
class Collection < ActiveRecord::Base
has_many :products, dependent: :nullify
end
class Product < ActiveRecord::Base
has_many :variants, dependent: :delete_all
belongs_to :type
class Type < ActiveRecord::Base
has_many :products
end
end
cl... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/engine.rb | activerecord/test/models/engine.rb | # frozen_string_literal: true
class Engine < ActiveRecord::Base
belongs_to :my_car, class_name: "Car", foreign_key: "car_id", counter_cache: :engines_count
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/too_long_table_name.rb | activerecord/test/models/too_long_table_name.rb | # frozen_string_literal: true
class TooLongTableName < ActiveRecord::Base
self.table_name = "toooooooooooooooooooooooooooooooooo_long_table_names"
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/paragraph.rb | activerecord/test/models/paragraph.rb | # frozen_string_literal: true
class Paragraph < ActiveRecord::Base
belongs_to :book
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/price_estimate.rb | activerecord/test/models/price_estimate.rb | # frozen_string_literal: true
class PriceEstimate < ActiveRecord::Base
include ActiveSupport::NumberHelper
belongs_to :estimate_of, polymorphic: true
belongs_to :thing, polymorphic: true
validates_numericality_of :price
def price
number_to_currency super
end
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/contact.rb | activerecord/test/models/contact.rb | # frozen_string_literal: true
module ContactFakeColumns
def self.extended(base)
base.class_eval do
establish_connection(adapter: "fake")
lease_connection.data_sources = [table_name]
lease_connection.primary_keys = {
table_name => "id"
}
column :id, "integer"
... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/keyboard.rb | activerecord/test/models/keyboard.rb | # frozen_string_literal: true
class Keyboard < ActiveRecord::Base
self.primary_key = "key_number"
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/job.rb | activerecord/test/models/job.rb | # frozen_string_literal: true
class Job < ActiveRecord::Base
has_many :references
has_many :people, through: :references
belongs_to :ideal_reference, class_name: "Reference"
has_many :agents, through: :people
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/hotel.rb | activerecord/test/models/hotel.rb | # frozen_string_literal: true
class Hotel < ActiveRecord::Base
has_many :departments
has_many :chefs, through: :departments
has_many :cake_designers, source_type: "CakeDesigner", source: :employable, through: :chefs
has_many :drink_designers, source_type: "DrinkDesigner", source: :employable, through: :chefs
... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/person.rb | activerecord/test/models/person.rb | # frozen_string_literal: true
class Person < ActiveRecord::Base
has_many :readers
has_many :secure_readers
has_one :reader
has_many :posts, through: :readers
has_many :secure_posts, through: :secure_readers
has_many :posts_with_no_comments, -> { includes(:comments).where("comments.id is null").references... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/uuid_child.rb | activerecord/test/models/uuid_child.rb | # frozen_string_literal: true
class UuidChild < ActiveRecord::Base
belongs_to :uuid_parent
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/strict_zine.rb | activerecord/test/models/strict_zine.rb | # frozen_string_literal: true
require "models/zine"
class StrictZine < Zine
self.strict_loading_by_default = true
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/zine.rb | activerecord/test/models/zine.rb | # frozen_string_literal: true
class Zine < ActiveRecord::Base
has_many :interests, inverse_of: :zine
has_many :polymorphic_humans, through: :interests, source_type: "Human"
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/dats.rb | activerecord/test/models/dats.rb | # frozen_string_literal: true
# DATS = Deprecated Associations Test Suite.
#
# Minimal models defined ad-hoc for the test suite of deprecated associations.
# They are persisted in existing tables for simplicity.
module DATS
def self.table_name_prefix = ""
require_relative "dats/author"
require_relative "dats/au... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/reply.rb | activerecord/test/models/reply.rb | # frozen_string_literal: true
require "models/topic"
class Reply < Topic
belongs_to :topic, foreign_key: "parent_id", counter_cache: true, inverse_of: :replies
belongs_to :topic_with_primary_key, class_name: "Topic", primary_key: "title", foreign_key: "parent_title", counter_cache: "replies_count", touch: true
... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/course.rb | activerecord/test/models/course.rb | # frozen_string_literal: true
require "models/arunit2_model"
class Course < ARUnit2Model
belongs_to :college
has_many :entrants
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/club.rb | activerecord/test/models/club.rb | # frozen_string_literal: true
class Club < ActiveRecord::Base
has_one :membership, touch: true
has_many :memberships, inverse_of: false
has_many :members, through: :memberships
has_one :sponsor
has_one :sponsored_member, through: :sponsor, source: :sponsorable, source_type: :Member
belongs_to :category
... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/image.rb | activerecord/test/models/image.rb | # frozen_string_literal: true
class Image < ActiveRecord::Base
belongs_to :imageable, polymorphic: true, foreign_key: :imageable_identifier, foreign_type: :imageable_class
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/column.rb | activerecord/test/models/column.rb | # frozen_string_literal: true
class Column < ActiveRecord::Base
belongs_to :record
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/notification.rb | activerecord/test/models/notification.rb | # frozen_string_literal: true
class Notification < ActiveRecord::Base
validates_presence_of :message
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/admin.rb | activerecord/test/models/admin.rb | # frozen_string_literal: true
module Admin
def self.table_name_prefix
"admin_"
end
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/dl_keyed_join.rb | activerecord/test/models/dl_keyed_join.rb | # frozen_string_literal: true
class DlKeyedJoin < ActiveRecord::Base
self.primary_key = "joins_key"
belongs_to :destroy_async_parent,
primary_key: :parent_id
belongs_to :dl_keyed_has_many_through,
primary_key: :through_key
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/arunit2_model.rb | activerecord/test/models/arunit2_model.rb | # frozen_string_literal: true
class ARUnit2Model < ActiveRecord::Base
self.abstract_class = true
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/branch.rb | activerecord/test/models/branch.rb | # frozen_string_literal: true
class Branch < ActiveRecord::Base
has_many :branches
belongs_to :branch, optional: true
end
class BrokenBranch < Branch
has_many :branches, class_name: "BrokenBranch", foreign_key: :branch_id
belongs_to :branch, optional: true, inverse_of: :branch, class_name: "BrokenBranch"
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/guid.rb | activerecord/test/models/guid.rb | # frozen_string_literal: true
class Guid < ActiveRecord::Base
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/seminar.rb | activerecord/test/models/seminar.rb | # frozen_string_literal: true
class Seminar < ActiveRecord::Base
has_many :sections, inverse_of: :seminar, autosave: true, dependent: :destroy
has_many :sessions, through: :sections
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/developer.rb | activerecord/test/models/developer.rb | # frozen_string_literal: true
require "models/computer"
class Developer < ActiveRecord::Base
module TimestampAliases
extend ActiveSupport::Concern
included do
alias_attribute :created_at, :legacy_created_at
alias_attribute :updated_at, :legacy_updated_at
alias_attribute :created_on, :lega... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/pk_autopopulated_by_a_trigger_record.rb | activerecord/test/models/pk_autopopulated_by_a_trigger_record.rb | # frozen_string_literal: true
class PkAutopopulatedByATriggerRecord < ActiveRecord::Base
self.primary_key = :id
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/cpk.rb | activerecord/test/models/cpk.rb | # frozen_string_literal: true
require_relative "cpk/author"
require_relative "cpk/book"
require_relative "cpk/order"
require_relative "cpk/review"
require_relative "cpk/order_agreement"
require_relative "cpk/order_tag"
require_relative "cpk/tag"
require_relative "cpk/chapter"
require_relative "cpk/post"
require_relati... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/company.rb | activerecord/test/models/company.rb | # frozen_string_literal: true
class AbstractCompany < ActiveRecord::Base
self.abstract_class = true
end
class Company < AbstractCompany
self.sequence_name = :companies_nonstd_seq
enum :status, [:active, :suspended]
validates_presence_of :name
has_one :account, foreign_key: "firm_id"
has_one :dummy_acco... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/warehouse_thing.rb | activerecord/test/models/warehouse_thing.rb | # frozen_string_literal: true
class WarehouseThing < ActiveRecord::Base
self.table_name = "warehouse-things"
validates_uniqueness_of :value
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/cat.rb | activerecord/test/models/cat.rb | # frozen_string_literal: true
class Cat < ActiveRecord::Base
self.abstract_class = true
enum :gender, [:female, :male]
default_scope -> { where(is_vegetarian: false) }
end
class Lion < Cat
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/user.rb | activerecord/test/models/user.rb | # frozen_string_literal: true
require "models/job"
class User < ActiveRecord::Base
has_secure_password validations: false
has_secure_password :recovery_password, validations: false
has_secure_token
has_secure_token :auth_token, length: 36
has_and_belongs_to_many :jobs_pool,
class_name: "Job",
join... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/sharded/tag.rb | activerecord/test/models/sharded/tag.rb | # frozen_string_literal: true
module Sharded
class Tag < ActiveRecord::Base
self.table_name = :sharded_tags
query_constraints :blog_id, :id
has_many :blog_post_tags
has_many :blog_posts, through: :blog_post_tags
end
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/sharded/blog_post_destroy_async.rb | activerecord/test/models/sharded/blog_post_destroy_async.rb | # frozen_string_literal: true
module Sharded
class BlogPostDestroyAsync < ActiveRecord::Base
self.table_name = :sharded_blog_posts
query_constraints :blog_id, :id
belongs_to :blog
has_many :comments, dependent: :destroy_async, foreign_key: [:blog_id, :blog_post_id], class_name: "Sharded::CommentDest... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/sharded/comment.rb | activerecord/test/models/sharded/comment.rb | # frozen_string_literal: true
module Sharded
class Comment < ActiveRecord::Base
self.table_name = :sharded_comments
query_constraints :blog_id, :id
belongs_to :blog_post
belongs_to :blog_post_by_id, class_name: "Sharded::BlogPost", foreign_key: :blog_post_id, primary_key: :id
belongs_to :blog
... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/sharded/comment_destroy_async.rb | activerecord/test/models/sharded/comment_destroy_async.rb | # frozen_string_literal: true
module Sharded
class CommentDestroyAsync < ActiveRecord::Base
self.table_name = :sharded_comments
query_constraints :blog_id, :id
belongs_to :blog_post, dependent: :destroy_async, foreign_key: [:blog_id, :blog_post_id], class_name: "Sharded::BlogPostDestroyAsync"
belong... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/sharded/blog_post_with_revision.rb | activerecord/test/models/sharded/blog_post_with_revision.rb | # frozen_string_literal: true
module Sharded
# copy of the original `BlogPost` class, but with a different `query_constraints`
class BlogPostWithRevision < ActiveRecord::Base
self.table_name = :sharded_blog_posts
query_constraints :blog_id, :revision, :id
has_many :comments, primary_key: [:blog_id, :i... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/sharded/blog.rb | activerecord/test/models/sharded/blog.rb | # frozen_string_literal: true
# Models under `Sharded` namespace represent an application that can be sharded by a `blog_id` column.
# `Blog` model plays the role of a tenant in the application.
# Being sharded by the `blog_id` means that queries to the database include the `blog_id` column in the clauses
# which serv... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/sharded/blog_post_tag.rb | activerecord/test/models/sharded/blog_post_tag.rb | # frozen_string_literal: true
module Sharded
class BlogPostTag < ActiveRecord::Base
self.table_name = :sharded_blog_posts_tags
query_constraints :blog_id, :id
belongs_to :blog_post
belongs_to :tag
end
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/sharded/blog_post.rb | activerecord/test/models/sharded/blog_post.rb | # frozen_string_literal: true
module Sharded
class BlogPost < ActiveRecord::Base
self.table_name = :sharded_blog_posts
query_constraints :blog_id, :id
belongs_to :parent, polymorphic: true
belongs_to :blog
has_many :comments
has_many :delete_comments, class_name: "Sharded::Comment", dependen... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/publisher/article.rb | activerecord/test/models/publisher/article.rb | # frozen_string_literal: true
class Publisher::Article < ActiveRecord::Base
has_and_belongs_to_many :magazines
has_and_belongs_to_many :tags
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/publisher/magazine.rb | activerecord/test/models/publisher/magazine.rb | # frozen_string_literal: true
class Publisher::Magazine < ActiveRecord::Base
has_and_belongs_to_many :articles
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/admin/randomly_named_c1.rb | activerecord/test/models/admin/randomly_named_c1.rb | # frozen_string_literal: true
class Admin::ClassNameThatDoesNotFollowCONVENTIONS1 < ActiveRecord::Base
self.table_name = :randomly_named_table2
end
class Admin::ClassNameThatDoesNotFollowCONVENTIONS2 < ActiveRecord::Base
self.table_name = :randomly_named_table3
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/admin/account.rb | activerecord/test/models/admin/account.rb | # frozen_string_literal: true
class Admin::Account < ActiveRecord::Base
has_many :users
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/admin/user_json.rb | activerecord/test/models/admin/user_json.rb | # frozen_string_literal: true
class Admin::UserJSON < ActiveRecord::Base
class Coder
def initialize(default = {})
@default = default
end
def dump(o)
ActiveSupport::JSON.encode(o || @default)
end
def load(s)
s.present? ? ActiveSupport::JSON.decode(s) : @default.clone
end
... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/admin/user.rb | activerecord/test/models/admin/user.rb | # frozen_string_literal: true
class Admin::User < ActiveRecord::Base
class Coder
def initialize(default = {})
@default = default
end
def dump(o)
ActiveSupport::JSON.encode(o || @default)
end
def load(s)
s.present? ? ActiveSupport::JSON.decode(s) : @default.clone
end
end
... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/dats/bulb.rb | activerecord/test/models/dats/bulb.rb | # frozen_string_literal: true
# DATS = Deprecated Associations Test Suite.
class DATS::Bulb < ActiveRecord::Base
belongs_to :car, class_name: "DATS::Car", dependent: :destroy, touch: true
belongs_to :deprecated_car, class_name: "DATS::Car", foreign_key: "car_id", dependent: :destroy, touch: true, deprecated: true
... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/dats/tire.rb | activerecord/test/models/dats/tire.rb | # frozen_string_literal: true
# DATS = Deprecated Associations Test Suite.
class DATS::Tire < ActiveRecord::Base
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/dats/category.rb | activerecord/test/models/dats/category.rb | # frozen_string_literal: true
# DATS = Deprecated Associations Test Suite.
class DATS::Category < ActiveRecord::Base
self.inheritance_column = nil
has_and_belongs_to_many :posts, class_name: "DATS::Post"
has_and_belongs_to_many :deprecated_posts, class_name: "DATS::Post", deprecated: true
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/dats/author.rb | activerecord/test/models/dats/author.rb | # frozen_string_literal: true
# DATS = Deprecated Associations Test Suite.
class DATS::Author < ActiveRecord::Base
has_many :posts, class_name: "DATS::Post", dependent: :destroy
has_many :deprecated_posts, class_name: "DATS::Post", dependent: :destroy, deprecated: true
has_many :comments, through: :posts, class... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/dats/comment.rb | activerecord/test/models/dats/comment.rb | # frozen_string_literal: true
# DATS = Deprecated Associations Test Suite.
class DATS::Comment < ActiveRecord::Base
self.inheritance_column = nil
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/dats/post.rb | activerecord/test/models/dats/post.rb | # frozen_string_literal: true
# DATS = Deprecated Associations Test Suite.
class DATS::Post < ActiveRecord::Base
self.inheritance_column = nil
belongs_to :author
has_many :comments, class_name: "DATS::Comment"
has_many :deprecated_comments, class_name: "DATS::Comment", deprecated: true
has_many :author_fa... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/dats/car.rb | activerecord/test/models/dats/car.rb | # frozen_string_literal: true
# DATS = Deprecated Associations Test Suite.
class DATS::Car < ActiveRecord::Base
self.lock_optimistically = false
has_many :tires, class_name: "DATS::Tire", dependent: :destroy
has_many :deprecated_tires, class_name: "DATS::Tire", dependent: :destroy, deprecated: true
accepts_n... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/dats/author_favorite.rb | activerecord/test/models/dats/author_favorite.rb | # frozen_string_literal: true
# DATS = Deprecated Associations Test Suite.
class DATS::AuthorFavorite < ActiveRecord::Base
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/autoloadable/extra_firm.rb | activerecord/test/models/autoloadable/extra_firm.rb | # frozen_string_literal: true
class ExtraFirm < Company
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/cpk/tag.rb | activerecord/test/models/cpk/tag.rb | # frozen_string_literal: true
module Cpk
class Tag < ActiveRecord::Base
self.table_name = :cpk_tags
has_many :order_tags
has_many :orders, through: :order_tags
end
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/cpk/order_tag.rb | activerecord/test/models/cpk/order_tag.rb | # frozen_string_literal: true
module Cpk
class OrderTag < ActiveRecord::Base
self.table_name = :cpk_order_tags
belongs_to :tag
belongs_to :order
end
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/cpk/book.rb | activerecord/test/models/cpk/book.rb | # frozen_string_literal: true
module Cpk
class Book < ActiveRecord::Base
attr_accessor :fail_destroy
self.table_name = :cpk_books
belongs_to :order, autosave: true, foreign_key: [:shop_id, :order_id], counter_cache: true
belongs_to :order_explicit_fk_pk, class_name: "Cpk::Order", foreign_key: [:shop... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/cpk/chapter.rb | activerecord/test/models/cpk/chapter.rb | # frozen_string_literal: true
module Cpk
class Chapter < ActiveRecord::Base
self.table_name = :cpk_chapters
# explicit definition is to allow schema definition to be simplified
# to be shared between different databases
self.primary_key = [:author_id, :id]
belongs_to :book, foreign_key: [:author... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/cpk/order.rb | activerecord/test/models/cpk/order.rb | # frozen_string_literal: true
module Cpk
class Order < ActiveRecord::Base
self.table_name = :cpk_orders
# explicit definition is to allow schema definition to be simplified
# to be shared between different databases
self.primary_key = [:shop_id, :id]
alias_attribute :id_value, :id
has_many ... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/cpk/book_destroy_async.rb | activerecord/test/models/cpk/book_destroy_async.rb | # frozen_string_literal: true
module Cpk
class BookDestroyAsync < ActiveRecord::Base
self.table_name = :cpk_books
has_many :chapters, foreign_key: [:author_id, :book_id], class_name: "Cpk::ChapterDestroyAsync", dependent: :destroy_async
end
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/cpk/order_agreement.rb | activerecord/test/models/cpk/order_agreement.rb | # frozen_string_literal: true
module Cpk
# This is a non composite primary key model that is associated with `Cpk::Order` via `id` only.
class OrderAgreement < ActiveRecord::Base
self.table_name = :cpk_order_agreements
belongs_to :order
end
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/cpk/review.rb | activerecord/test/models/cpk/review.rb | # frozen_string_literal: true
module Cpk
class Review < ActiveRecord::Base
self.table_name = :cpk_reviews
belongs_to :book, class_name: "Cpk::Book", foreign_key: [:author_id, :number]
end
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/cpk/author.rb | activerecord/test/models/cpk/author.rb | # frozen_string_literal: true
module Cpk
class Author < ActiveRecord::Base
self.table_name = :cpk_authors
has_many :books, class_name: "Cpk::Book", dependent: :delete_all
end
end
| ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/cpk/comment.rb | activerecord/test/models/cpk/comment.rb | # frozen_string_literal: true
module Cpk
class Comment < ActiveRecord::Base
self.table_name = :cpk_comments
belongs_to :commentable, foreign_key: %i[commentable_title commentable_author], polymorphic: true
belongs_to :post, class_name: "Cpk::Post", foreign_key: %i[commentable_title commentable_author]
... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
rails/rails | https://github.com/rails/rails/blob/ba0d6f09e991d0621cc30f19c9d189cd21dbf76e/activerecord/test/models/cpk/post.rb | activerecord/test/models/cpk/post.rb | # frozen_string_literal: true
module Cpk
class Post < ActiveRecord::Base
self.table_name = :cpk_posts
has_many :comments, class_name: "Cpk::Comment", foreign_key: %i[commentable_title commentable_author], as: :commentable
has_many :posts_tags, class_name: "Cpk::PostsTag", foreign_key: %i[post_title post_... | ruby | MIT | ba0d6f09e991d0621cc30f19c9d189cd21dbf76e | 2026-01-04T15:37:27.222351Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.