Forum: Ruby on Rails beginner - multiobject searches

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
7d74329100dbb655c864a8bbabb74cd3?d=identicon&s=25 Marty Henderson (Guest)
on 2006-02-15 16:49
Hi folks,

Bit confused by rails and the active record stuff for searching across
tables.

Say I have a property which has an address and I want to search to
provide a form that takes one item and searches across both the address
and property tables... how do I go about it?

Thanks in advance

Marty
337cdd270761e0e6f4356de45b04d388?d=identicon&s=25 Jonathan Viney (jonny)
on 2006-02-16 11:50
I read your question twice and still have no idea what you are trying to
do :). Perhaps if you made it a little clearer we can help.

Cheers, -Jonny.
25e11a00a89683f7e01e425a1a6e305c?d=identicon&s=25 Wilson Bilkovich (Guest)
on 2006-02-16 16:13
(Received via mailing list)
On 2/15/06, Marty Henderson <henderson.marty@gmail.com> wrote:
> Hi folks,
>
> Bit confused by rails and the active record stuff for searching across
> tables.
>
> Say I have a property which has an address and I want to search to
> provide a form that takes one item and searches across both the address
> and property tables... how do I go about it?
>

Does this help?
http://rails.techno-weenie.net/question/2006/1/13/...
A2b2f4ee23989dc68529baef9cbddcd6?d=identicon&s=25 Julian 'Julik' Tarkhanov (Guest)
on 2006-02-16 17:19
(Received via mailing list)
On 15-feb-2006, at 16:49, Marty Henderson wrote:

> Hi folks,
>
> Bit confused by rails and the active record stuff for searching across
> tables.
>
> Say I have a property which has an address and I want to search to
> provide a form that takes one item and searches across both the
> address
> and property tables... how do I go about it?

If you have many models with the same attribute (and you want to
search across these models but in this attribute only)

[Person, Company].inject([]) do | result, class |
	result += class.find_all_by_address(address_query)
end
7d74329100dbb655c864a8bbabb74cd3?d=identicon&s=25 Marty Henderson (Guest)
on 2006-02-16 17:57
Julian 'Julik' Tarkhanov wrote:
> On 15-feb-2006, at 16:49, Marty Henderson wrote:
>
>> Hi folks,
>>
>> Bit confused by rails and the active record stuff for searching across
>> tables.
>>
>> Say I have a property which has an address and I want to search to
>> provide a form that takes one item and searches across both the
>> address
>> and property tables... how do I go about it?
>
> If you have many models with the same attribute (and you want to
> search across these models but in this attribute only)
>
> [Person, Company].inject([]) do | result, class |
> 	result += class.find_all_by_address(address_query)
> end


cheers for the help folks.
did it just using sql for simplicity..
This topic is locked and can not be replied to.