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

has_many << fails when pushing a relation subclass

    • Type: Icon: Task Task
    • Resolution: Done
    • 4.0.0 final
    • Affects Version/s: None
    • Component/s: None
    • None

      I have this situation using v4 beta1:

      class Exercsie
         has_many :repetitions
      end
      
      class Repetition
         belongs_to :exercise
      end
      
      class ParticularRepetition < Repetition
      
      end
      

      Based on some condition a push in repetitions a subclass of Repetition.

      This works:

      exercise.repetitions.push  Repetition.new
      

      This brakes with the following exception.

      exercise.repetitions.push  ParticularRepetition.new
      ArgumentError: wrong number of arguments (1 for 0)
      from ............mongoid-4.0.0.beta1/lib/mongoid/fields.rb:477:in `block (2 levels) in create_field_check'
      

      Am a doing something wrong or is a possible bug?

            Assignee:
            Unassigned Unassigned
            Reporter:
            andreacfm Andrea Campolonghi
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: