public
Created

  • Download Gist
gistfile1.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
class ParentClass < ActiveRecord::Base
has_many :child_classes
end
 
class ChildClass < ActiveRecord::Base
belongs_to :parent_class
 
def self.class_method(csv_row)
# Pivots the CSV row into a set of ChildClass instances with a reference to parent_class_instance
# Like
end
end
 
# I want to do this:
 
parent_class_instance.child_classes.class_method
 
#like running
parent_class_instance.child_classes.create(hash)
 
# but creating a set of instances, not a single instance

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.