Use a random string as id in Ruby on Rails?

后端 未结 4 720
暖寄归人
暖寄归人 2021-02-06 18:45

I want to create a web app similar to http://www.pastebin.com/ in Ruby on Rails. pastebin.com uses a random string to identify an item. Ruby on Rails uses an auto-incrementing n

4条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-06 19:02

    I believe you can override the implementation of to_param in the models of interest. There's a fuller explanation of the technique here

提交回复
热议问题