Skip to content
Snippets Groups Projects
Commit 5d5b3e30 authored by Alex Reisner's avatar Alex Reisner
Browse files

Merge branch 'master' of github.com:alexreisner/geocoder

parents 097ee983 e7ded194
No related branches found
No related tags found
No related merge requests found
...@@ -255,7 +255,7 @@ module Geocoder::Store ...@@ -255,7 +255,7 @@ module Geocoder::Store
# #
def add_exclude_condition(conditions, exclude) def add_exclude_condition(conditions, exclude)
if exclude if exclude
conditions[0] << " AND #{full_column_name(:id)} != ?" conditions[0] << " AND #{full_column_name(primary_key)} != ?"
conditions << exclude.id conditions << exclude.id
end end
conditions conditions
......
# encoding: utf-8
require 'test_helper'
class ActiveRecordTest < Test::Unit::TestCase
def test_exclude_condition_when_model_has_a_custom_primary_key
venue = VenuePlus.new(*venue_params(:msg))
# just call private method directly so we don't have to stub .near scope
conditions = venue.class.send(:add_exclude_condition, ["fake_condition"], venue)
assert_match( /#{VenuePlus.primary_key}/, conditions.join)
end
end
...@@ -35,6 +35,17 @@ module ActiveRecord ...@@ -35,6 +35,17 @@ module ActiveRecord
read_attribute name read_attribute name
end end
end end
class << self
def table_name
'test_table_name'
end
def primary_key
:id
end
end
end end
end end
...@@ -192,6 +203,20 @@ class Venue < ActiveRecord::Base ...@@ -192,6 +203,20 @@ class Venue < ActiveRecord::Base
end end
end end
##
# Geocoded model.
# - Has user-defined primary key (not just 'id')
#
class VenuePlus < Venue
class << self
def primary_key
:custom_primary_key_id
end
end
end
## ##
# Reverse geocoded model. # Reverse geocoded model.
# #
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment