This project is archived and is in readonly mode.

#241 ✓resolved
José Valim

Added :select options to has_one and belongs_to

Reported by José Valim | May 23rd, 2008 @ 10:32 AM

Now, since we preload associations, :select options will work great in has_one and in belongs_to, so I've added this option.

But a bug is also fixed in this patch:

Currently belongs_to accepts the :order key, but it wasn't used when we were going to find the association, i.e. setting it wouldn't change a thing (active_record/associations/belongs_to_association.rb, line 43):

def find_target



:conditions => conditions,

:include => @reflection.options[:include],

:readonly => @reflection.options[:readonly]



Since it doesn't make sense having a order in belongs_to (this behavior wasn't even in tests), I took the key out, basically removing it from the assert valid keys args and updating the documentation.

Test included.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>

People watching this ticket