我正在开发Ruby on Rails中的RESTful应用程序接口。使用gem jsonapi-resources。
我想实现一个路由,比如/me。它应该总是路由到/account/:id,其中id是当前登录用户的id。
因此,/account/:id/tasks应该与/me/tasks相同。
有谁能告诉我怎么走吗?
发布于 2016-08-03 23:38:58
你可以这样做:
namespace :me do
get '/', to: 'accounts#show'
get '/tasks', to: 'tasks#index'
end然后,在控制器中检索当前用户(如果使用Devise,则使用current_user )
https://stackoverflow.com/questions/38747927
复制相似问题