ruby on rails - has_many Using class Versus class_name -
i've been modelling custom has_many associations this:
has_many :friends, class: user i found style isn't documented , api docs:
has_many :friends, class_name: 'user' i haven't noticed problems former syntax, , i'm curious why later syntax used (wouldn't better avoid converting string class?). reason switch former later?
well in coming version of rails class has been renamed anonymous_class. although still in master branch. there problem use of :class , here goes commit :
in 1f006c option added called :class allow passing anonymous classes association definitions. since using :class instead of :class_name common typo amongst experienced developers can result in hard debug errors arising in raise_on_type_mismatch?
to fix we're renaming option :class :anonymous_class more correct description of option for. since internal, undocumented option there no need deprecation.
it in 4-2-stable
rename
:class:anonymous_classin association options. fixes #19659
Comments
Post a Comment