Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-463

Association callbacks not used

    • Type: Icon: Task Task
    • Resolution: Done
    • 12_01_17
    • Affects Version/s: None
    • Component/s: None
    • Labels:

      ActiveRecord has association callbacks for before/after add/remove that would be nice to support. This is a particularly contrived example, but I think it may make particular sense for the front for a NoSQL DB (where denormalization is more common) to support:

      class Person
      field :city
      references_many :pets, :after_add => :inherit_city

      def inherit_city(pet)
      pet.city = self.city
      end
      end

      class Pet
      field :city
      referenced_in :person
      end

      The relevant ActiveRecord code that handles this is: https://github.com/rails/rails/blob/master/activerecord/lib/active_record/associations/association_collection.rb

            Assignee:
            Unassigned Unassigned
            Reporter:
            doxavore Doug Mayer
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: