Skip to content

Instantly share code, notes, and snippets.

@anathematic
Created April 21, 2010 03:29
Show Gist options
  • Save anathematic/373383 to your computer and use it in GitHub Desktop.
Save anathematic/373383 to your computer and use it in GitHub Desktop.
def build_payable_by_attributes
# Automatically build payable_by - in javascript we'll give the user control to change these on ContractIspsController#new
payable_by.eql?("shared") ? count = 3 : count = 1
remove_older_payment_amounts
count.times do
payable_amounts.build(:amount => 0) if payable_amounts.size != count
end
end
def remove_older_payment_amounts
payable_amounts.each { |p| p.destroy }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment