I'm trying to get the geocoder gem to work on an object that has been filtered using a has_many relationship
like so
user.rb
has_one :profile
has_many :roles
name:string
profile.rb
belongs_to :user
latitude,latitude:float, address:string, city:string
role.rb
belongs_to :user
name:string
the problem I'm having is I need to filter the roles to say id => 3
so we have
@limitrole = User.includes(:profile, :roles).where('roles.id' => 3)
this returns an object of limited roles, now grab the profile that contains the geocode stuff
@profiles = @limitrole.collect { |user| user.profile }
This returns an object of addresses limited to the users role
But this won't work
@findlocations = @profiles.near('city, country', 20) (city and country being arbitrary values)
Yet this will work
@findlocations = Profile.near('city, country', 20)
@profiles should be the same as Profile (both objects) it's just @profiles has been filtered.
How do I get this to work?