diff --git a/CHANGELOG.md b/CHANGELOG.md index 1afe8bc..a3ab0c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 0.1.2 (2015-04-12) + +- Let `Model#find` work with integers passed in as strings. + ## 0.1.1 (2015-04-12) - Let `Model#find` work with integer model ids as well as hashids. diff --git a/lib/hashid/rails.rb b/lib/hashid/rails.rb index 3c63856..6565197 100644 --- a/lib/hashid/rails.rb +++ b/lib/hashid/rails.rb @@ -27,15 +27,11 @@ def encode_id(id) end def decode_id(id) - hashids.decode(id).first + hashids.decode(id.to_s).first end def find(hashid) - if hashid.is_a? String - super decode_id(hashid) - else - super hashid - end + super decode_id(hashid) || hashid end end end diff --git a/lib/hashid/rails/version.rb b/lib/hashid/rails/version.rb index 835847a..6ca04dd 100644 --- a/lib/hashid/rails/version.rb +++ b/lib/hashid/rails/version.rb @@ -1,5 +1,5 @@ module Hashid module Rails - VERSION = '0.1.1' + VERSION = '0.1.2' end end