Skip to content

Commit

Permalink
Let Model#find work with integers passed in as strings.
Browse files Browse the repository at this point in the history
  • Loading branch information
jcypret committed Apr 13, 2015
1 parent 05faeef commit 9cd061f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
8 changes: 2 additions & 6 deletions lib/hashid/rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/hashid/rails/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Hashid
module Rails
VERSION = '0.1.1'
VERSION = '0.1.2'
end
end

0 comments on commit 9cd061f

Please sign in to comment.