Skip to content

Instantly share code, notes, and snippets.

@corntrace
Created September 20, 2010 09:48
Show Gist options
  • Save corntrace/587669 to your computer and use it in GitHub Desktop.
Save corntrace/587669 to your computer and use it in GitHub Desktop.
module Embedding
def embeds_many(association_id, options = {})
has_many association_id, options.merge(:dependent => :destroy)
accepts_nested_attributes_for association_id, :allow_destroy => true
end
def embeds_one(association_id, options = {})
has_one association_id, options.merge(:dependent => :destroy)
accepts_nested_attributes_for association_id, :allow_destroy => true
end
end
ActiveRecord::Base.extend Embedding
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment