Skip to content

Instantly share code, notes, and snippets.

@iberianpig
Last active August 29, 2015 14:23
Show Gist options
  • Save iberianpig/3785451d6802a8e3eaa1 to your computer and use it in GitHub Desktop.
Save iberianpig/3785451d6802a8e3eaa1 to your computer and use it in GitHub Desktop.
3桁"/"区切りのurlを生成する。paperclipで生成されるurlをidから作る。
#NOTE: create id_hash for paperclip's url
# e.g) photo_id = 14721; format("%09d", photo_id).split("").each_slice(3).map{ |array| array.join("") }.join("/")
# # => "000/014/721"
id_hash = format("%09d", photo_id).split("").each_slice(3).map{ |array| array.join("") }.join("/")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment