Is there any way to define custom routes in Phoenix?

后端 未结 4 1194
夕颜
夕颜 2021-02-05 08:59

Let\'s say I want to create a resources with adding a couple of custom actions to it, the analogue in rails is:

resources :tasks do
  member do
             


        
4条回答
  •  清酒与你
    2021-02-05 09:06

    I want to improve Dogbert's answer a little bit:

    resources "/tasks", TaskController do
      get "/implement", TaskController, :implement, as: :implement
    end
    

    The only addition is as: :implement in the end of the route.

    Thus you will get route named task_implement_path instead of ugly task_task_path.

提交回复
热议问题