-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers
Description
this controller action is a bloody mess and could probably be improved.
def index
@services = Service.published.page(params[:page]).joins(:categories).preload(:categories).distinct
if params[:postcode].present?
@locations = Geocoder.search(params[:postcode], region: "gb")
@services = @services.kinda_near(@locations.first.coordinates) if @locations.present?
flash[:alert] = "Couldn't find any services near that location. Is it a valid postcode or area in Camden?" if @services.empty? || @locations.blank?
end
@services = @services.category(params[:category]) if params[:category].present?
respond_to do |format|
format.html
format.json { render json: ServiceSerializer.new(@services).serializable_hash }
end
end
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers