lib/sluggable_finder/orm.rb in sluggable_finder-2.2.2 vs lib/sluggable_finder/orm.rb in sluggable_finder-2.3.0

- old
+ new

@@ -18,11 +18,12 @@ :from => field, :scope => nil, :to => :slug, :reserved_slugs => [], :allow_integer_ids => true, - :upcase => false + :upcase => false, + :ignore_sti => false # if true, Uniqueness won't check sibling classes. }.merge( options )) class_inheritable_reader :sluggable_finder_options if sluggable_finder_options[:scope] scope_condition_method = %( @@ -93,12 +94,17 @@ cond = if new_record? '' else "id != #{id} AND " end + _type_column = slugable_class.inheritance_column + _class_name = self.class.name + puts 'AAAAAAAAAAAAAAAAAA' + _class_name slugable_class.transaction do #case insensitive - existing = slugable_class.find(:first, :conditions => ["#{cond}#{destination_column} LIKE ? and #{scope_condition}", proposed_slug + suffix]) + conds_sql = "#{cond}#{destination_column} LIKE ? and #{scope_condition}" + conds_sql << " and #{_type_column} = '#{_class_name}'" if sluggable_finder_options[:ignore_sti] + existing = slugable_class.find(:first, :conditions => [conds_sql, proposed_slug + suffix]) while existing != nil or sluggable_finder_options[:reserved_slugs].include?(proposed_slug + suffix) if suffix.empty? suffix = "-2" else suffix.succ! \ No newline at end of file