Multiple models to be used for a single row
Closed this issue · 1 comments
mkhanal commented
Our CSV's single row represents multiple models, which may or may not have an ActiveRelation amongst themselves. it would be awesome to have multiple models with columns mapping for each models.
pcreux commented
I'd recommend creating a proxy object that responds to .transaction
, .find_by
and #save
. :)
class AllTheThings
def self.transaction
ActiveRecord::Base.transaction do
yield
end
end
def self.find_by(attributes)
# ...
end
def save
# ...
build_one_thing.save && build_the_other_thing
end
end