What is the proper way of defining indexes on associated models with following configuration?
I have model Locality
with lat
and lng
attributes and associated models Profile
and User
class User < ActiveRecord::Base
has_one :user_profile
define_index do
# This doesn't work :(
has "RADIANS(user_profiles.localities.lat)", :as => :lat, :type => :float
has "RADIANS(user_profiles.localities.lng)", :as => :lng, :type => :float
end
end
end
class UserProfile < ActiveRecord::Base
belongs_to :user
belongs_to :locality
end
class Locality < ActiveRecord::Base
has_many :user_profiles
end
I need to define indexes for User model so I can perform geo-searches on it.
Thank you for the answers!