I have a table for neighborhoods with a name and an id
Also have a table for assets, each asset have a neighborhood_id
Asset model => belongs to neighborhood
Neighborhood model => has many assets
I have a page where I list all assets, and a search form to find
assets by selecting from a list of neighborhoods.
The list of neighborhoods is taken from the neighborhoods table
@list_all_neighborhoods = Neighborhood.find(:all, :order => "name")
<%= collection_select(:asset, :neighborhood_id,
@list_all_neighborhoods, :id, :name) %>
Now if I search for a neighborhood that do not exist in one of the
assets I get a message like "no results try something else"
I want to eliminate that message and show on the search form only
neighborhoods that actually exist in the assets table.
I understand that i need to take the @list_all_neighborhoods array and
check each record to see if exist in the assets table
But I can't make this work
I appreciate any help
The website is online here http://www.5354.co.il
It is in Hebrew