lib/sluggable_finder/orm.rb in sluggable_finder-2.3.3 vs lib/sluggable_finder/orm.rb in sluggable_finder-2.3.4
- old
+ new
@@ -76,11 +76,12 @@
end
def get_value_or_generate_random(column_name)
v = self.send(column_name)
v = sluggable_finder_options[:slug_modifier].call(v) if sluggable_finder_options[:slug_modifier]
- v || SluggableFinder.random_slug_for(self.class)
+ encoded = SluggableFinder.encode(v.to_s)
+ (v.present? && encoded.present?) ? v : SluggableFinder.random_slug_for(self.class)
end
def create_sluggable_slug
suffix = ''
begin
@@ -118,6 +119,6 @@
end
end
end
-end
\ No newline at end of file
+end