mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
504a9d5010
In 7f938ca
the test model `Man` was renamed to `Human`. Maybe this is a
good time to also change `horrible_human` and `dirty_human` to
`happy_human` and `confused_human`.
While this change is mostly cosmetic change, the phrase "dirty man" has
a negative meaning.
The adjectives "confused" and "puzzled" were chosen because they are
used for defining associations with errors.
38 lines
1.3 KiB
Ruby
38 lines
1.3 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
class Human < ActiveRecord::Base
|
|
self.table_name = "humans"
|
|
|
|
has_one :face, inverse_of: :human
|
|
has_one :polymorphic_face, class_name: "Face", as: :polymorphic_human, inverse_of: :polymorphic_human
|
|
has_one :polymorphic_face_without_inverse, class_name: "Face", as: :poly_human_without_inverse
|
|
has_many :interests, inverse_of: :human
|
|
has_many :interests_with_callbacks,
|
|
class_name: "Interest",
|
|
before_add: :add_called,
|
|
after_add: :add_called,
|
|
inverse_of: :human_with_callbacks
|
|
has_many :polymorphic_interests,
|
|
class_name: "Interest",
|
|
as: :polymorphic_human,
|
|
inverse_of: :polymorphic_human
|
|
has_many :polymorphic_interests_with_callbacks,
|
|
class_name: "Interest",
|
|
as: :polymorphic_human,
|
|
before_add: :add_called,
|
|
after_add: :add_called,
|
|
inverse_of: :polymorphic_human
|
|
# These are "broken" inverse_of associations for the purposes of testing
|
|
has_one :confused_face, class_name: "Face", inverse_of: :confused_human
|
|
has_many :secret_interests, class_name: "Interest", inverse_of: :secret_human
|
|
has_one :mixed_case_monkey
|
|
|
|
attribute :add_callback_called, :boolean, default: false
|
|
|
|
def add_called(_interest)
|
|
self.add_callback_called = true
|
|
end
|
|
end
|
|
|
|
class SuperHuman < Human
|
|
end
|