Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 707635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:18:01+00:00 2026-05-14T04:18:01+00:00

github url I am using a simple search that displays search results: @adds =

  • 0

github url

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?

Model:

def self.search(search)
    if search
      find(:all, :conditions => ['address LIKE ?', "%#{search}%"])
      # where('address LIKE ?', "%#{search}")
    else
      find(:all)
    end
  end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T04:18:01+00:00Added an answer on May 14, 2026 at 4:18 am

    When you find(2), a model object is returned, but if you find(:all), and array is returned.

    The nearbys method is only going to work on an instance of the model object. What if your search method returns an array of 10 addresses? You can’t just invoke nearby on the array, you have to loop thru your array and apply nearby to each address yielded in the loop.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I cloned a repo using its GitHub read-only URL onto my team's staging server.
I'm using nodejs to create a simple proxy server that logs http and https
I am following the guidelines published here: http://develop.github.com/p/repo.html I am trying to add a
I'm trying to get a simple file upload working using jquery-fileupload-rails carrierwave fog I
I have really simple few lines of Facebook app, using the new Facebook API:
Using the sample app for rpx_now gem ( http://github.com/grosser/rpx_now_example ) on localhost:3000, I have
I am using SignalR(https://github.com/SignalR/SignalR) in my project. From here https://github.com/SignalR/SignalR/wiki/QuickStart-Hubs I got the idea
I am trying to build a project-page setup that auto populates the project details
Github offers a way to let a URL know when a project has been
I am using the PHP SDK Version 3.1.1 in order to make a simple

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.