Skip to content

Relationship with polymorphic: true doesn't set base_class in field_type #45

@mateusamerico

Description

@mateusamerico

I have the following code:

class Parent < ActiveRecord::Base
  include Tenacity
  t_has_many :cars, as: :owner
end

class Child < Parent
  attr_accessible :type
end

class Car
  include Mongoid::Document
  include Mongoid::Timestamps
  include Tenacity

  t_belongs_to :owner, polymorphic: true
  attr_accessible :owner
end

Running the command on console: car = Car.new(owner: Child.new) I have the result:
car.owner_type: "Child"

But the expected behavior from polymorphic using ActiveRecord is:
car.owner_type: "Parent"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions