Skip to content

Instantly share code, notes, and snippets.

@mikecmpbll
Created June 26, 2014 00:03
Show Gist options
  • Save mikecmpbll/b1e428cccbb73e8f0b29 to your computer and use it in GitHub Desktop.
Save mikecmpbll/b1e428cccbb73e8f0b29 to your computer and use it in GitHub Desktop.
def update_status
order_statuses = self.rows.joins(row_status: :order_status).group('order_status.id').pluck('order_status.id')
self.order_status_id = order_statuses.one? ? order_statuses.pop : OrderStatus.find_by(name: "processing").id
self.save!
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment