Rails routes: GET without param :id

后端 未结 7 1043
名媛妹妹
名媛妹妹 2021-01-01 08:56

I\'m developing a REST api based on rails. To use this api, you MUST be logged in. Regarding that, I\'d like to create a method me in my user controller that wi

7条回答
  •  南笙
    南笙 (楼主)
    2021-01-01 09:30

      resources :users, only: [:index, :update] do
        collection do
          get :me, action: 'show' 
        end
      end
    

    specifying the action is optional. you can skip action here and name your controller action as me.

提交回复
热议问题