Skip to content

Instantly share code, notes, and snippets.

@awongh
Created July 18, 2013 01:43
Show Gist options
  • Save awongh/6026091 to your computer and use it in GitHub Desktop.
Save awongh/6026091 to your computer and use it in GitHub Desktop.
class CandyJar < ActiveRecord::Base
has_many :candies
accepts_nested_attributes_for :candies, :reject_if => lambda { |a| a[:pricing_type_id].blank? }, :allow_destroy => true
#custom validators for nested attributes arrays
validate :has_candy #returns true if at least one candy attribute is passed
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment