I'm trying to get my head around inverse_of
and I do not get it.
What does the generated sql look like, if any?
Does the inverse_of
option exhibit the same behavior if used with :has_many
, :belongs_to
, and :has_many_and_belongs_to
?
Sorry if this is such a basic question.
I saw this example:
class Player < ActiveRecord::Base
has_many :cards, :inverse_of => :player
end
class Card < ActiveRecord::Base
belongs_to :player, :inverse_of => :cards
end
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…