Skip to content

Instantly share code, notes, and snippets.

@niallsmart
Last active August 29, 2015 14:06
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 niallsmart/8f57bab4cc6da2659c86 to your computer and use it in GitHub Desktop.
Save niallsmart/8f57bab4cc6da2659c86 to your computer and use it in GitHub Desktop.
Set last comment/last proposal on restored deals
ActiveRecord::Base.logger = Logger.new(STDERR)
ActiveRecord::Base.logger.level = Logger::DEBUG
deal_ids = [11929, 11930, 11928, 11927, 12166, 11933, 11934, 12369, 11984, 11931, 11924, 11922, 11921, 11920, 11919, 11926, 11923];
Deal.where(id: deal_ids).find_each do |deal|
deal.update_column :last_comment_id, deal.comments.last.try(:id)
deal.update_column :last_proposal_id, deal.proposals.last.try(:id)
deal.update_column :last_dying_update_id, deal.updates.where(type: 'DealDyingUpdate').last.try(:id)
deal.update_column :last_executed_update_id, deal.updates.where(type: 'DealExecutedUpdate').last.try(:id)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment