Hello Everyone,
I am pretty new to ROR and am stuck on how to proceed. I have an
application that stores businesses along with there delivery boundaries.
The boundaries are stored as 4 latitude/longitude points. When a user
does a search they enter there address and I need to bring back all of
the businesses that deliver to them.
I use what’s called a Point in Poly algorithm to determine if a business
delivers to the input address.
In my controller I set the result variable to a call to Search in the
model like so…
@businesses = Business.search(params[:search])
In my model I have…
def self.search(search)
@all Businesses= find(:all)
for bus in 0…@ @all Businesses.length
if( inPoly?(How do I get the attributes of bus to pass to inPoly?))
How Do I add this bus to my result list?
end
end
How do I return my new list to the controller?
end
def self.inPoly?(point1,point2,point3,point4,testPoint)
I can do this
end
What I am really stuck on is how I can build my list in my search
function. I am not sure how to access the attributes of each business in
the for loop. And I am not sure how to return the result to the
controller. Any help at all would be really apprectiated.