what i might do is have 2 sets of search results
#simple search
def search
@manufacturers = Manufacturer.find(:all, :conditions => ["LOWER(name)
like
?", "%#{@params[:criteria].downcase}%"])
@parts = Parts.find(:all, :conditions => ["LOWER(name) like ? or
LOWER(part_no) like ?", "%#{@params[:criteria].downcase}%",
"%#{@params[:criteria].downcase}%"])
end
then in your view, display the matches in sections
Manufacturers: found <%= @manufacturers.size -%> matches to
"<%@params[:criteria] %>"
<%# interate though matched manufacturers %>
Parts: found <%= @parts.size -%> matches to "<%=
@params[:criteria] %>"
<%# interate though matched parts %>
On 3/14/06, don cameron <a8723@cameronsoftware.com>
wrote:>
> Looking for some guidance, I seem to be caught in the weeds.
>
> I want to do a search on fields in a master/detail relationship.
>
> E.g. manufacturer owns many parts. I want to search on the
> manufacturer name, part name and part number, then return the full set
> of results.
>
> I have tried to use the .find method and create my own model .find
> method using a SQL statement, but then the results do not get properly
> mapped back to the objects.
>
> What is the accepted strategy for this simple query?
>
> thanks
> Don
>
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://wrath.rubyonrails.org/pipermail/rails/attachments/20060314/445c4e1d/attachment.html