Hi,
I'm currently using Mongomapper within a Padrino project where I'm importing data from an external source. The main object (Application) has two associated document types, Activity and Notice.
However, I'd like to specify the foreign key myself, rather than use the internal Mongo ID, as the foreign key is in the data export, which I import via a rake task.
I've tried an EmbeddedDocument, but this causes issues as I have to delete all the associated data, rather than updating it, which isn't ideal.
I've tried the following, but without any luck:
class Application
include MongoMapper::Document
ensure_index [[:latlng, '2d']]
key :refval, String
key :pkeyval, String
key :applicantname, String
key :latlng, Array
key :address, String
key :occupier, String
key :type, String
key :casetype, String
key :tradingname, String
key :closingdate, Date
key :recieveddate, Date
key :details, String
key :usetype, String
key :status, String
key :validfrom, Date
timestamps!
many :activities, :foreign_key => :pkeyval
many :notices, :foreign_key => :pkeyval
end
class Activity
include MongoMapper::Document
key :keyval, String
key :pkeyval, String
key :type, String
key :cycle, String
key :open, String
key :close, String
belongs_to :application, :foreign_key => :pkeyval
end
class Notice
include MongoMapper::Document
key :keyval, String
key :pkeyval, String
key :recieveddate, Date
key :startdate, Date
key :enddate, Date
key :days, String
key :hours, String
key :activities, Array
belongs_to :application, :foreign_key => :pkeyval
end
Any ideas where I'm going wrong?