Ruby jsonapi-resources链接(相对/绝对)

时间:2017-06-08 12:35:52

标签: ruby jsonapi-resources

我对Ruby非常陌生,所以如果这个问题看起来非常简单或模糊,我会提前道歉。

使用jsonapi-resources时,指定JSON API链接的基本路径是什么?我希望从指定完整网址到root-relative路径更改为这些资源。

我找到了routes.rb

Rails.application.routes.draw do

# Route / to the front-end
root to: 'root#index'

namespace :api do

   jsonapi_resources :widgets

   // ...more jsonapi_resources calls
end

1 个答案:

答案 0 :(得分:1)

我猜你在找这样的东西?

Rails.application.routes.draw do
  namespace :api do
    namespace :v1 do
      jsonapi_resources :cars, only: [:index]
    end
  end
end