Sha256: 21c55174dbce3dc8aca292581051a5ed87898575b27ace0871a6f820da9accc2

Contents?: true

Size: 638 Bytes

Versions: 6

Compression:

Stored size: 638 Bytes

Contents

module Basepack
  class ImportImportable < ActiveRecord::Base
    self.table_name = :imports_importables

    klass = Basepack::Settings.import.model_name.safe_constantize
    belongs_to :import, inverse_of: :importables, class_name: "::#{klass}"

    if Basepack::Settings.import.association_name
      belongs_to :importable, polymorphic: true, inverse_of: Basepack::Settings.import.association_name_join_table
    else
      belongs_to :importable, polymorphic: true
    end

    validates_presence_of :import, :importable

    def to_label
      import.try(:to_label)
    end

    rails_admin do
      visible false
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
basepack-1.0.1 app/models/basepack/import_importable.rb
basepack-1.0.0 app/models/basepack/import_importable.rb
basepack-1.0.0.pre.0 app/models/basepack/import_importable.rb
basepack-0.2.0 app/models/basepack/import_importable.rb
basepack-0.1.0 app/models/basepack/import_importable.rb
basepack-0.0.2 app/models/basepack/import_importable.rb