Skip to content

Instantly share code, notes, and snippets.

@willrjmarshall
Created February 3, 2012 03:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save willrjmarshall/1727570 to your computer and use it in GitHub Desktop.
Save willrjmarshall/1727570 to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment