has_permalink 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/has_permalink.rb +6 -2
- metadata +4 -4
data/lib/has_permalink.rb
CHANGED
@@ -21,7 +21,11 @@ module HasPermalink
|
|
21
21
|
# find(params[:id]) is quering the permalink field if it's a string
|
22
22
|
#
|
23
23
|
def find(*args)
|
24
|
-
|
24
|
+
if args.class == Array && (args.first.class == String || args.first.class == Fixnum) && args.length == 1
|
25
|
+
find_by_permalink!(*args)
|
26
|
+
else
|
27
|
+
super(*args)
|
28
|
+
end
|
25
29
|
end
|
26
30
|
|
27
31
|
# Makes it possible to generate permalinks for
|
@@ -60,7 +64,7 @@ module HasPermalink
|
|
60
64
|
# Autofix duplication of permalinks
|
61
65
|
def fix_duplication(permalink)
|
62
66
|
if auto_fix_duplication
|
63
|
-
n = self.class.where(
|
67
|
+
n = self.class.where(["permalink LIKE ?", "#{permalink}%"]).count
|
64
68
|
|
65
69
|
if n > 0
|
66
70
|
resolve_duplication(permalink, n)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: has_permalink
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ola Karlsson
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-06-
|
18
|
+
date: 2011-06-25 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|