mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-05 22:26:07 +00:00
Fixed the bug in the enterprise geo search.
This commit is contained in:
@@ -47,8 +47,8 @@ class EnterprisesController < BaseController
|
||||
|
||||
def search
|
||||
@suburb = Suburb.find(params[:suburb_id]) if params[:suburb_id].present?
|
||||
@enterpsises = Enterprise.find_near(@suburb)
|
||||
@enterprises_json = @enterpsises.to_gmaps4rails
|
||||
@enterprises = Enterprise.find_near(@suburb).limit(10)
|
||||
@enterprises_json = @enterprises.to_gmaps4rails
|
||||
render :layout => "landing_page"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -76,7 +76,7 @@ class Enterprise < ActiveRecord::Base
|
||||
enterprises = []
|
||||
|
||||
unless suburb.nil?
|
||||
addresses = Spree::Address.near([suburb.latitude, suburb.longitude], ENTERPRISE_SEARCH_RADIUS, :units => :km).limit(10)
|
||||
addresses = Spree::Address.near([suburb.latitude, suburb.longitude], ENTERPRISE_SEARCH_RADIUS, :units => :km).joins(:enterprise)
|
||||
enterprises = addresses.collect(&:enterprise)
|
||||
end
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
- if @enterpsises.any?
|
||||
- if @enterprises.any?
|
||||
.row.full-width
|
||||
.large-4.columns
|
||||
- if @suburb.present?
|
||||
@@ -7,7 +7,7 @@
|
||||
You have searched at:
|
||||
%strong
|
||||
%div= "#{@suburb.name}, #{@suburb.state_name}"
|
||||
- @enterpsises.each do |enterprise|
|
||||
- @enterprises.each do |enterprise|
|
||||
.row.search-result.with-separator
|
||||
.large-12.columns
|
||||
= link_to enterprise.name, shop_front_enterprise_path(enterprise.id)
|
||||
|
||||
Reference in New Issue
Block a user