Class: Leva::Dataset

Inherits:
ApplicationRecord show all
Defined in:
app/models/leva/dataset.rb

Instance Method Summary collapse

Instance Method Details

#add_record(record) ⇒ Leva::DatasetRecord?

Adds a record to the dataset if it doesn’t already exist

Parameters:

  • record (ActiveRecord::Base)

    The record to be added to the dataset

Returns:



22
23
24
25
26
# File 'app/models/leva/dataset.rb', line 22

def add_record(record)
  dataset_records.find_or_create_by(recordable: record) do |dr|
    dr.recordable = record
  end
end