Change the name of the :id parameter in Routing resources for Rails

前端 未结 5 1441
难免孤独
难免孤独 2020-12-04 10:11

I looked around on how to change the dynamic params slot and found this post that does the exact thing. The post is https://thoughtbot.com/blog/rails-patch-change-the-name-o

5条回答
  •  佛祖请我去吃肉
    2020-12-04 10:45

    If I understand you correctly, what you want is to have the client_name instead of id in your url, right?

    You can do that by overriding the to_param method in your model. You can get more information here.

提交回复
热议问题