#8357 Specifying association class via :class instead of :class_name

34 views
Skip to first unread message

Gary Weaver

unread,
Nov 28, 2012, 5:26:18 PM11/28/12
to rubyonra...@googlegroups.com
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.

Will Bryant

unread,
Nov 28, 2012, 6:02:20 PM11/28/12
to rubyonra...@googlegroups.com
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 <garys...@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 rubyonra...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-co...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.

Reply all
Reply to author
Forward
0 new messages