Replies: 1 comment 7 replies
-
Hey @cperezabo -- I'm afraid the solution isn't as simple as you're hoping. A big part of the problem here is that Not knowing exactly what you're wanting the end goal to look like, it's hard to know what to recommend. If at all possible, you'll want to make sure the The best approach is to ensure that your Mongoid model classes are dedicated Mongoid model classes, designed around class Dummy
class Model
include Mongoid::Document
field :name, type: String
end
attr_accessor :name
def initialize(name:)
@name = name
end
def to_model
Model.new(name: name)
end
# ...
end If there is any shared behavior between the Mongoid model and the pure-Ruby version, extract it to a module that you can include into each version. Again, this might be severely over-engineering things, since I don't know what your requirements are, but hopefully I've given you some ideas to think about. |
Beta Was this translation helpful? Give feedback.
-
Hi everyone!
Suppose I have the following class:
At some point I want to convert it into a Document by sending it the expected messages:
But it doesn't work, objects are not even saved and there is no error at all when sending the
save!
message.I've also tried prepending the
Mongoid::Document
module but it breaks completelyAny idea on how to achieve this?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions