sql - Missing Attribute after applying joins and merge on Rails -


i have 2 models;

category  has_many :locations  location  belongs_to :category reverse_geocoded_by :latitude, :longitude |obj,results|  if geo = results.first     obj.address = geo.address     obj.city    = geo.city     obj.country = geo.country_code  end end after_validation :reverse_geocode 

when apply, nearest category location. used near scope in geocoder gem here.

category.joins(:locations).merge(location.near("tignale")) 

in sql

    select locations.*, (69.09332411348201 * abs(locations.latitude - 45.7426301) * 0.7071067811865475) + (59.836573914187355 * abs(locations.longitude - 10.7091062) * 0.7071067811865475) distance, case when (locations.latitude >= 45.7426301 , locations.longitude >= 10.7091062)  45.0 when (locations.latitude <  45.7426301 , locations.longitude >= 10.7091062) 135.0 when (locations.latitude <  45.7426301 , locations.longitude <  10.7091062) 225.0 when (locations.latitude >= 45.7426301 , locations.longitude <  10.7091062) 315.0 end bearing "categories" inner join "locations" on "locations"."category_id" =  "categories"."id" (locations.latitude between 45.4531665337783 , 46.0320936662217 , locations.longitude between 10.29433218237017 , 11.123880217629832)  order distance asc 

i this.

[#<category:0xb090be0   id: 3,   created_at: thu, 03 sep 2015 21:46:12 utc +00:00,   updated_at: sat, 05 sep 2015 21:36:19 utc +00:00>] 

some other attributes on category models missing example 'name' etc.


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -