1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
Commit graph

10 commits

Author SHA1 Message Date
Daniel Colson
7f938cacba
Replace test Man with Human
The commit replaces the `Man` model used in tests with a `Human` model. It
also replaces the existing `Human` model with a `SuperHuman` model
inheriting from `Human`.

While this may seem like a cosmetic change, I see it as more of an
inclusivity change. I think it makes sense for a number of reasons:

* Prior to this commit the `Human` model inherited from `Man`. At best
  this makes no sense (it should be the other way around). At worst it
  is offensive and harmful to the community.
* It doesn't seem inclusive to me to have exclusively male-gendered
  examples in the codebase.
* There is no particular reason for these examples to be gendered.
* `man` is hard to grep for, since it also matches `many, manager,
  manual, etc`

For the most part this is a simple search and replace. The one exception
to that is that I had to add the table name to the model so we could use
"humans" instead of "humen".
2020-08-14 11:37:09 -04:00
Gannon McGibbon
61401184e9 Don't run callbacks on has_many inverse add
Stop running association callbacks when setting `has_many` inverse
records. The `before_add` and `after_add` callbacks are meant for
newly added records.
2019-10-10 16:18:13 -04:00
Kir Shatrov
831be98f9a Use frozen-string-literal in ActiveRecord 2017-07-19 22:27:07 +03:00
Matthew Draper
87b3e226d6 Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"
This reverts commit 3420a14590, reversing
changes made to afb66a5a59.
2017-07-02 02:15:17 +09:30
Kir Shatrov
cfade1ec7e Enforce frozen string in Rubocop 2017-07-01 02:11:03 +03:00
Xavier Noria
d22e522179 modernizes hash syntax in activerecord 2016-08-06 19:37:57 +02:00
wangjohn
d6b03a3767 Getting rid of the +automatic_inverse_of: false+ option in associations in favor
of using +inverse_of: false+ option. Changing the documentation and
adding a CHANGELOG entry for the automatic inverse detection feature.
2013-06-08 10:16:51 -07:00
wangjohn
26d19b4661 Created a method to automatically find inverse associations and cache
the results. Added tests to check to make sure that inverse associations are
automatically found when has_many, has_one, or belongs_to associations
are defined.
2013-05-07 23:24:43 -04:00
George Ogata
81ca0cf2b0 Add inverse polymorphic association support. [#3520 state:resolved]
Signed-off-by: Eloy Duran <eloy.de.enige@gmail.com>
2009-12-28 15:12:13 +01:00
Murray Steele
ccea98389a Providing support for :inverse_of as an option to associations.
You can now add an :inverse_of option to has_one, has_many and belongs_to associations.  This is best described with an example:

class Man < ActiveRecord::Base
  has_one :face, :inverse_of => :man
end

class Face < ActiveRecord::Base
  belongs_to :man, :inverse_of => :face
end

m = Man.first
f = m.face

Without :inverse_of m and f.man would be different instances of the same object (f.man being pulled from the database again).  With these new :inverse_of options m and f.man are the same in memory instance.

Currently :inverse_of supports has_one and has_many (but not the :through variants) associations.  It also supplies inverse support for belongs_to associations where the inverse is a has_one and it's not a polymorphic.

Signed-off-by: Murray Steele <muz@h-lame.com>
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2009-05-04 15:27:39 -07:00