Sutto / slugged

Super simple slugs for ActiveRecord 3+, with slug history. Formerly known as Pseudocephalopod.
MIT License
86 stars 16 forks source link

Editable slugs #3

Closed gzigzigzeo closed 13 years ago

gzigzigzeo commented 13 years ago

There is a case when user should be able to manually change a slug for an object. For example let we have Page model with sluggable name field used to construct russian site urls. User creates a contact information page:

Page.create(:name => "Контактная информация")

Page slug will be "kontaktnaya-informaciya", but it is very difficult to remeber and read in translit. So, best variant is to change this slug manually to "contacts" during page creation.

Page.create(:name => "Контактная информация", :slug_cache => "contacts")

I think, it will be useful to allow user to manually edit cached_slug field. The rule is simple: generate slug unless cached_slug_changed?, otherwise parameterize (convert) cached_slug and save.

Also, we should validate_uniqueness_of a slug, and may be add a sequence.

What do you think about it? I had implemented this, but I am not shure that it is elegant solution.

gzigzigzeo commented 13 years ago

Also it would be useful to preview a slug for an item.