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 -- Posted via http://www.ruby-forum.com/.
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. -- Posted via http://www.ruby-forum.com/.
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/how_to_create_searches_across_multiple_fields_using_various_search_criteria
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
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) > endcheers for the help folks. did it just using sql for simplicity.. -- Posted via http://www.ruby-forum.com/.