Created
July 21, 2017 01:13
-
-
Save cainlevy/574041ce4517737ca50aa554a4d1f4f0 to your computer and use it in GitHub Desktop.
Revisions
-
cainlevy renamed this gist
Jul 21, 2017 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
cainlevy created this gist
Jul 21, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ # forgiveness is faster than permission private def catch_uniqueness_errors yield rescue ActiveRecord::RecordNotUnique => e field = e.cause.message.match(/index_([a-z_]*)_on_([a-z_]*)/)[2] raise unless field errors.add(field, :taken) end