Ruby on Rails Tuesday, February 19, 2013

Hi there !


I'm doing a rails engine and I have written several ruby modules in it that will be included in the models of the future client Rails applications.

I'm facing a weird issue now : The modules inside my engine use massively mongoid. (To append fields to models, declare indexes and stuff) But when I use the DateTime type for some fields, it will throw a NoMethod error on save like :
undefined method `__bson_dump__' for XXXX

I checked the sources of Mongoid and identified where all the extension logic (for DateTime especially) was implemented. 
Is it that I did not properly require dependencies or something ?

Because I have correctly added mongoid gem to my engine dependencies gemspec and I even require 'mongoid' in my engine.rb file, so that all the initialization of mongoid could be entirely done before my engine initializes itself.


Thank you for your attention

One of my module looks like :

module Event

   included do
      include Mongoid::Document
      field :starts_at, :type => DateTime
   end

end

class MyEvent
   include Engine::Event
end

MyEvent.new :starts_at => DateTime.now

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/WEyaiIcTLIAJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment