Best practices to handle routes for STI subclasses in rails

后端 未结 18 1317
面向向阳花
面向向阳花 2020-11-30 16:25

My Rails views and controllers are littered with redirect_to, link_to, and form_for method calls. Sometimes link_to and <

18条回答
  •  南笙
    南笙 (楼主)
    2020-11-30 16:49

    You can try this, if you have no nested routes:

    resources :employee, path: :person, controller: :person
    

    Or you can go another way and use some OOP-magic like described here: https://coderwall.com/p/yijmuq

    In second way you can make similar helpers for all your nested models.

提交回复
热议问题