This project is archived and is in readonly mode.
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
@reflection.klass.find(
@owner[@reflection.primary_key_name],
:conditions => conditions,
:include => @reflection.options[:include],
:readonly => @reflection.options[:readonly]
)
end
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
-
Repository May 24th, 2008 @ 06:58 AM
- State changed from new to resolved
(from [8d0b4fa39fab6e5d1e3382b4b137cc47e559b0be]) Added :select option to has_one and belongs_to, remove unused :order option on belongs_to.
Signed-off-by: Michael Koziarski
[#241 state:resolved]
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="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>