hashid-rails 0.3.2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 57c692d5064faea88ae4b6f088c69bdbfd0ab54e
4
- data.tar.gz: ec1b561f21d8550635dd082c584105c48c19e49c
3
+ metadata.gz: fef0e8c5ec9d05c05dc0d392931d87b9551a6cef
4
+ data.tar.gz: a0f05a0e3161396920c4fc8561694654cad4dd7e
5
5
  SHA512:
6
- metadata.gz: e021ef31cedc780f17346d4eb282ea318ed572c09dd15577b2158e2668d9042f0dadb8ad5f371507b706a4a4b7324168d462c13cd06f326db844d49dbadc7a42
7
- data.tar.gz: 4a9fd16a4baa41f920e58d8d26652b35e3daab18899849f2613cfda7cf22cb5f5c33f645d671af1097d2ae34ed225373757307666f24faa95871cf662b4794cd
6
+ metadata.gz: 18b71e3b28eedafb5af85e9c737b0f90cc5a4ae4af138551d0644ac3b693def5aa02ff53b76a3acc6c0e35c55c744e2c38b762510d677a37dc9fd1b4a97c48d0
7
+ data.tar.gz: adabcf0504c995fdd5df9b76f2bf90abb031190bde2c8f51c6adce729bc26c4f20ead54874322d7a53355618eb90df099e80a51294333f3287926a878d40f199
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.0 (2016-08-21)
4
+ - Add `find_by_hashid` method to always try and decode, as opposed to `find` which tries to find it as an integer first.
5
+
3
6
  ## 0.3.2 (2016-03-30)
4
7
  - Multiple ids can be passed to `find` method
5
8
 
data/README.md CHANGED
@@ -29,14 +29,29 @@ Or install it yourself as:
29
29
  $ gem install hashid-rails
30
30
  ```
31
31
 
32
- ## Usage
32
+ ## Basic Usage
33
33
 
34
- Just use `Model#find` passing in the hashid instead of the model id:
34
+ Just use `Model#find` passing in the hashid instead of the model id.
35
35
 
36
36
  ```ruby
37
37
  @person = Person.find(params[:hashid])
38
38
  ```
39
39
 
40
+ ## Alternative Usage
41
+
42
+ You can use the `Model#find_by_hashid` method to find a record without falling
43
+ back on the standard `find` method. This can be useful in cases where the hashid
44
+ might be misinterpreted by the `find` method, such as using a hashid containing
45
+ only numbers that could be both interpreted as either an id and or a hashid.
46
+
47
+ ```ruby
48
+ # When a record is found, it returns the record.
49
+ @person = Person.find_by_hashid(params[:hashid])
50
+
51
+ # When no record, is found it raises an exception.
52
+ ActiveRecord::RecordNotFound
53
+ ```
54
+
40
55
  ## Configuration
41
56
 
42
57
  To customize the Hashids seed and ensure that another user of the gem cannot
@@ -66,7 +66,6 @@ module Hashid
66
66
  model_reload? ? super(hashid) : super( decode_id(hashid) || hashid )
67
67
  end
68
68
 
69
- # Calls `find` with decoded hashid
70
69
  def find_by_hashid(hashid)
71
70
  find_by!(id: hashid_decode(hashid))
72
71
  end
@@ -1,5 +1,5 @@
1
1
  module Hashid
2
2
  module Rails
3
- VERSION = '0.3.2'
3
+ VERSION = '0.4.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hashid-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Cypret
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-03-31 00:00:00.000000000 Z
11
+ date: 2016-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -130,4 +130,3 @@ signing_key:
130
130
  specification_version: 4
131
131
  summary: Use Hashids in your Rails app models.
132
132
  test_files: []
133
- has_rdoc: