vogomatix
vogomatix

Reputation: 5061

Ruby jsonapi-resources links (relative/absolute)

I am incredibly new to Ruby, so I apologise in advance if this question seems very simple or vague.

Where, when using jsonapi-resources is the base path for JSON API links specified? I wish to change from specifying full URLs to root-relative paths to these resources.

I've found the routes.rb which has

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

Upvotes: 0

Views: 161

Answers (1)

Severin
Severin

Reputation: 8588

I am guessing you are looking for something like this?

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

Upvotes: 1

Related Questions