Skip to content

Instantly share code, notes, and snippets.

@chenghung
Created November 13, 2014 02:36
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 chenghung/a0596299542e062f943b to your computer and use it in GitHub Desktop.
Save chenghung/a0596299542e062f943b to your computer and use it in GitHub Desktop.
10 def get_sequence(name)
11 data = self.find_or_create_by id: name
12
13 data.with_lock do # could not get lock error here
14 data.sequence += 1
15 data.save!
16
17 data.sequence
18 end
19 end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment