norman/friendly_id — pull request #177 by lawitschka (2011-10-26 17:19:28+00:00)
Title: Fixing "Duplicate entry on slug" when using Single Table Inheritance

Hey everyone,

i ran into an issue with the newest version (4.0.0 Beta) of Friendly ID when using Single Table Inheritance.

The problem is that the slug generator is looking for an existing slug by accessing the table via `sluggable.class`. If sluggable is a STI model you're only accessing the instances of this concrete subclass and not all possible instances. Doing it this way you do not recognize a duplicate slug entry, the generator is not notifying any conflicts, no sequence will be created and SQL finally throws an exception (if you defined an unique index on the column).

I hereby submit a quick solution for the problem. This works (to my knowledge) in the regular case, STI case and even Multiple Table Inheritance case.

I'd appreciate the acceptance of the pull request. If you do know any easier solution I'd be happy to hear it :)

Best regards

P.S.: The first commits are a quick and dirty fix for a live system. Do not judge me by this attempt ;)