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.
Marty H. (Guest)
on 2006-02-15 17: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
Jonathan V. (Guest)
on 2006-02-16 12: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.
Wilson B. (Guest)
on 2006-02-16 17:13
(Received via mailing list)
On 2/15/06, Marty H. <removed_email_address@domain.invalid> 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/...
Julian 'Julik' Tarkhanov (Guest)
on 2006-02-16 18:19
(Received via mailing list)
On 15-feb-2006, at 16:49, Marty H. 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
Marty H. (Guest)
on 2006-02-16 18:57
Julian 'Julik' Tarkhanov wrote:
> On 15-feb-2006, at 16:49, Marty H. 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.