0 votes
in Ruby by
Given this code, which statement about the database table "documents" could be expected to be true?

class Document < ActiveRecord::Base

  belongs_to :documentable, polymorphic: true

end

class Product < ActiveRecord::Base

  has_many :documents, as: :documentable

end

class Service < ActiveRecord::Base

  has_many :documents, as: :documentable

end

 a. It would include a column for :type.

 b. It would include columns for :documentable_id and :documentable_type.

 c. It would include columns for :documentable and :type.

 d. It would include a column for :polymorphic_type.

1 Answer

0 votes
by
Given this code, which statement about the database table "documents" could be expected to be true?

class Document < ActiveRecord::Base

  belongs_to :documentable, polymorphic: true

end

class Product < ActiveRecord::Base

  has_many :documents, as: :documentable

end

class Service < ActiveRecord::Base

  has_many :documents, as: :documentable

end

Correct answer is :-  It would include columns for :documentable_id and :documentable_type.
...