Skip to content

Instantly share code, notes, and snippets.

module AccountSlug
PATTERN = /(\d{7,})/
FORMAT = '%07d'
def self.decode(slug) slug.to_i end
def self.encode(id) FORMAT % id end
# We're using account id prefixes in the URL path. Rather than namespace
# all our routes, we're "mounting" the Rails app at this URL prefix.
#