Beginner - multiobject searches


#1

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


#2

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.


#3

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/how_to_create_searches_across_multiple_fields_using_various_search_criteria


#4

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…


#5

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