Skip to content

Instantly share code, notes, and snippets.

@kryhtin
Created December 10, 2015 10:20
Show Gist options
  • Save kryhtin/b3740a3b83c120edd746 to your computer and use it in GitHub Desktop.
Save kryhtin/b3740a3b83c120edd746 to your computer and use it in GitHub Desktop.
class PropertiesLocationCollection
include ActionView::Helpers
include Rails.application.routes.url_helpers
def initialize(properties)
@properties = properties
end
def build
@locations = @properties.map do |property|
{ lat: property.owner.profile.location.lat.to_s,
lon: property.owner.profile.location.lon.to_s,
path: company_path(property.owner),
company: property.owner.profile.company_name.upcase }
end.uniq
end
def json
@locations.to_json
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment