Best way to generate slugs (human-readable IDs) in Rails

前端 未结 12 863
北荒
北荒 2020-11-30 18:05

You know, like myblog.com/posts/donald-e-knuth.

Should I do this with the built in parameterize method?

What about a plugin? I could imagine a plugin being n

12条回答
  •  执念已碎
    2020-11-30 18:47

    In Rails you can use #parameterize

    For example:

    > "Foo bar`s".parameterize 
    => "foo-bar-s"
    

提交回复
热议问题