как связать 2 таблички из монги на рельсах через айдишник?
коллекция locations
{
"_id" : ObjectId("222d1a2980401829b6a74912"),
"state" : "Россия",
"district" : "Томская область"
}
коллекция users
{
"_id" : ObjectId("61dd3a2280401819b6a74912"),
"name" : "Игорь",
"number" : 2,
"location_id" : ObjectId("222d1a2980401829b6a74912")
}
модель Location
class Location
include Mongoid::Document
include Mongoid::Timestamps
field :state, type: String
field :district, type: String
# belongs_to :user, inverse: :location
end
модель User
class User
include Mongoid::Document
include Mongoid::Timestamps
#store_in collection: "user"
field :name, type: String
field :number, type: String
belongs_to :location , class_name: Location # class_name: Location в моем случае не обязательно
end