Skip to content

Only join to through_table from selecting_distance_from when there is one #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/activerecord-postgres-earthdistance/acts_as_geolocated.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ module ActiveRecordPostgresEarthdistance
MILES_TO_METERS_FACTOR = 1609.344
module ActsAsGeolocated
extend ActiveSupport::Concern


module ClassMethods

module ClassMethods
def acts_as_geolocated(options = {})
begin
if table_exists?
Expand Down Expand Up @@ -95,7 +95,7 @@ def self.quote_value(value)
module QueryMethods
def selecting_distance_from(lat, lng, name = "distance", include_default_columns = true)
clone.tap do |relation|
relation.joins!(through_table)
relation.joins!(through_table) if through_table
values = []
if relation.select_values.empty? && include_default_columns
values << relation.arel_table[Arel.star]
Expand Down