nagybence-railhead_permalink 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/railhead_permalink.rb +5 -4
- data/railhead_permalink.gemspec +1 -1
- metadata +1 -1
data/lib/railhead_permalink.rb
CHANGED
@@ -26,7 +26,7 @@ module RailheadPermalink
|
|
26
26
|
def find_with_permalink(*args)
|
27
27
|
key = args.first
|
28
28
|
if key.is_a?(String)
|
29
|
-
find_without_permalink(:first, :conditions =>
|
29
|
+
find_without_permalink(:first, :conditions => {:permalink => key}) || find_without_permalink(*args)
|
30
30
|
else
|
31
31
|
find_without_permalink(*args)
|
32
32
|
end
|
@@ -39,9 +39,10 @@ module RailheadPermalink
|
|
39
39
|
key, counter = self[permalink_options[:field]].parameterize.to_s, '-1'
|
40
40
|
unless self.permalink == key
|
41
41
|
permalink = key
|
42
|
-
while permalink_options[:reserved_names].include?(permalink) or
|
43
|
-
|
44
|
-
|
42
|
+
while permalink_options[:reserved_names].include?(permalink) or
|
43
|
+
(self.class.exists?(:permalink => permalink) and not self == self.class.find_without_permalink(:first, :conditions => {:permalink => permalink}))
|
44
|
+
counter.succ!
|
45
|
+
permalink = key + counter
|
45
46
|
end
|
46
47
|
self[:permalink] = permalink
|
47
48
|
end
|
data/railhead_permalink.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "railhead_permalink"
|
3
|
-
s.version = "0.1.
|
3
|
+
s.version = "0.1.7"
|
4
4
|
s.date = "2009-01-28"
|
5
5
|
s.summary = "RailheadPermalink is a Ruby on Rails plugin that automatically finds ActiveRecord objects with permalink."
|
6
6
|
s.email = "nagybence@tipogral.hu"
|