cascade_callbacks not working using before_create and <<

XMLWordPrintableJSON

    • Fully Compatible
    • None
    • None
    • None
    • None
    • None
    • None

      I experienced the following behavior:

      class Parent
          include Mongoid::Document
      
          embeds_many :things, :cascade_callbacks => true
      
          before_create :initialize_first_thing
      
          def initialize_first_thing
              self.things << Thing.new(:name => "first")
          end
      end
      
      class Thing
          include Mongoid::Document
          include Mongoid::Timestamps
      
          embedded_in :parent
      
          field :name, :type => String
      
          before_create lambda {puts "before_create"}
      end
      

      When I create the parent, the before_create on Thing does not run, neither the timestamps are saved.

      Am I missing something?

            Assignee:
            Neil Shweky (Inactive)
            Reporter:
            rafaels
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: