hakanensari/mongoid-slug — pull request #51 by DouweM (2012-02-25 00:55:06+00:00)
Title: Support for reserved slugs

Same as #32, but updated to the current state of `master`.

Description for @siong1987's #32:

> This is useful if I have a higher level slug like "about" which is supposed to point to the About page.
>
> Without reserved slugs, it might return a slug named "about" which will crash with the slug of the About page.
>
> With reserved slugs, we can prevent this because the first slug that is returned will be "about-1" instead of "about".
>
> To reserve slugs so that they will not be used as slugs, pass an array of reserved slugs into `:reserve`:
>
> ```ruby
> class Friend
> include Mongoid::Document
> field :name
> slug :name, :reserve => ['foo', 'bar']
> end
> ```
>
> Reserved slugs will instead start with suffix "-1". For the example above,
>
> ```ruby
> friend = Friend.create(:name => "foo") # first foo friend
> friend.slug # returns "foo-1" instead of "foo" since "foo" is reserved
> ```