Skip to content

Instantly share code, notes, and snippets.

@mage2k
Created December 2, 2008 17:41
Show Gist options
  • Select an option

  • Save mage2k/31190 to your computer and use it in GitHub Desktop.

Select an option

Save mage2k/31190 to your computer and use it in GitHub Desktop.
# Returns the current ID of a table's sequence.
def last_insert_id(table, sequence_name) #:nodoc:
Integer(select_value("SELECT currval('#{sequence_name}')"))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment