Forum: Rails-core (closed, excessive spam) Why belongs_to doesn't have :select, :group, :offset and :limit options?

Posted by José Valim (josevalim)
on 2008-05-22 18:08
(Received via mailing list)
I was just wondering, cause with preload associations wouldn't be a
problem to support those keys.

So if no problem actually exists, I'm offering myself to do a patch. =)
Posted by José Valim (josevalim)
on 2008-05-22 19:15
(Received via mailing list)
Ok! I was out of my mind!
My problem is really with the :select key and I just thought, why not
include others also? =P

:group, :offset and :limit keys don't make sense.

So, changing my question: why belongs_to and has_one doesn't
support :select options?

Really, we only have to change 2 lines of code! =)
Posted by José Valim (josevalim)
on 2008-05-22 21:52
(Received via mailing list)
Actually, I'm not the only one crazy! =)

Does anyone know why belongs_to accepts :order?
Cause it isn't even in the find_target method (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

Thanks,
José Valim.
Posted by José Valim (josevalim)
on 2008-05-23 11:33
(Received via mailing list)
Posted by Michael Koziarski (Guest)
on 2008-05-24 08:02
(Received via mailing list)
Nicely done, applied.

On Fri, May 23, 2008 at 7:51 AM, José Valim <jose.valim@gmail.com> wrote:
>            :conditions => conditions,
>> My problem is really with the :select key and I just thought, why not
>>
>> > I was just wondering, cause with preload associations wouldn't be a
>> > problem to support those keys.
>>
>> > So if no problem actually exists, I'm offering myself to do a patch. =)
> >
>



--
Cheers

Koz
This topic is locked and can not be replied to.