Skip to content

Instantly share code, notes, and snippets.

Created March 1, 2012 20:39
Show Gist options
  • Save anonymous/1953080 to your computer and use it in GitHub Desktop.
Save anonymous/1953080 to your computer and use it in GitHub Desktop.
monthly_data = book.monthly_data.order("call_date DESC")
price_data = book.price_data.order("date DESC")
price_data.each do |row|
catch :skip_row do
row_date = row.date.to_date
case
when row_date > monthly_data.first.call_date
row.update_attributes(:monthly_datum_id => monthly_data.first.id)
when row_date == monthly_data.first.call_date
monthly_data.shift
throw :skip_row
when row_date < monthly_data.first.call_date
monthly_data.shift
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment