Gary Weaver
2012-Nov-28 22:26 UTC
#8357 Specifying association class via :class instead of :class_name
https://github.com/rails/rails/pull/8357 I have a ton of models where class_name is specified in associations and have been thinking for a while about doing something about it other than just using class_name: TheClassName which saves a few quote chars, but it still has to be changed to string and re-constantized if do it with class_name, so why not save 5 more chars and just use :class. At least, that was the thought. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-core/-/OwBCJ2I7b1oJ. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Will Bryant
2012-Nov-28 23:02 UTC
Re: #8357 Specifying association class via :class instead of :class_name
Don''t do that. The class has to load at the point where you reference your constant; If you did that, when you''re partway through loading one class, Ruby has to go off and load the other class. That''s not a good thing. On 29/11/2012, at 11:26 , Gary Weaver <garysweaver@gmail.com> wrote:> https://github.com/rails/rails/pull/8357 > > I have a ton of models where class_name is specified in associations and have been thinking for a while about doing something about it other than just using class_name: TheClassName which saves a few quote chars, but it still has to be changed to string and re-constantized if do it with class_name, so why not save 5 more chars and just use :class. At least, that was the thought. > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. > To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-core/-/OwBCJ2I7b1oJ. > To post to this group, send email to rubyonrails-core@googlegroups.com. > To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.