Sha256: d0f026d9b68cd7d1fa9fbec82a0bc65b27fb852a97b5b2e6944f20f84bf044e8

Contents?: true

Size: 427 Bytes

Versions: 3

Compression:

Stored size: 427 Bytes

Contents

class PartObjectField < ActiveRecord::Base

  belongs_to :part_object, class_name: "PartObject", foreign_key: "part_object_id"
  belongs_to :fieldable, polymorphic: true, dependent: :destroy

  validates :fieldable, presence: true
  accepts_nested_attributes_for :fieldable, allow_destroy: true

  def build_fieldable(attributes, options = {})
    self.fieldable = fieldable_type.constantize.new(attributes, options)
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
activeadmin-magicfields-0.4.2 lib/app/models/part_object_field.rb
activeadmin-magicfields-0.4.1 lib/app/models/part_object_field.rb
activeadmin-magicfields-0.4.0 lib/app/models/part_object_field.rb