Rails3. How do I display two different objects in a search?

Posted by JZ on Stack Overflow See other posts from Stack Overflow or by JZ
Published on 2010-04-07T22:07:11Z Indexed on 2010/04/07 22:53 UTC
Read the original article Hit count: 305

I am using a simple search that displays search results:

@adds = Add.search(params[:search])

In addition to the search results I'm trying to utilize a method, nearbys(), which displays objects that are close in proximity to the search result. The following method displays objects which are close to 2, but it does not display object 2. How do I display object 2 in conjunction with the nearby objects?

@adds = Add.find(2).nearbys(10)

While the above code functions, when I use search, @adds = Add.search(params[:search]).nearbys(10) a no method error is returned, undefined methodnearbys' for Array:0x30c3278`

How can I search the model for an object AND use the nearbys() method AND display all results returned?

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about ruby-on-rails3