Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Added :select options to has_one and belongs_to

#241

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.

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

State: resolved
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. Repository
    Repository
    • 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]

    http://github.com/rails/rails/co...

    May 24th, 2008 @ 06:58 AM