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

Association callbacks not used

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: 12_01_17
    • Component/s: None
    • Labels:

      Description

      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

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved: