mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Moved limit into the model.
This commit is contained in:
@@ -47,7 +47,7 @@ class EnterprisesController < BaseController
|
||||
|
||||
def search
|
||||
@suburb = Suburb.find(params[:suburb_id]) if params[:suburb_id].present?
|
||||
@enterprises = Enterprise.find_near(@suburb).limit(10)
|
||||
@enterprises = Enterprise.find_near(@suburb)
|
||||
@enterprises_json = @enterprises.to_gmaps4rails
|
||||
render :layout => "landing_page"
|
||||
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).joins(:enterprise)
|
||||
addresses = Spree::Address.near([suburb.latitude, suburb.longitude], ENTERPRISE_SEARCH_RADIUS, :units => :km).joins(:enterprise).limit(10)
|
||||
enterprises = addresses.collect(&:enterprise)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user