does it make sense to keep the class name in the field when using inheritance with mongomapper / rails?
class Item
include MongoMapper::Document
timestamps!
key :class, String
key :title, String
end
class Post < Item
key :body1, String
end
class Page < Item
key :body2, String
end
If an item is searched, MongoMapper will return Item objects. it is unclear what objects they are. if we want to display an icon or something similar to distinguish objects from each other, this can be done by storing the class name in db. Does this make sense, or is there a better way?
railsmongo
source
share