0

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
vogomatix
  • 4,856
  • 2
  • 23
  • 46
  • can you show some code on what you are trying to accomplish – gates Jun 08 '17 at 12:38
  • I'm looking at a lot of existing code and want to know what sort of command, configuration or class initialisation that would set this up – vogomatix Jun 08 '17 at 12:59

1 Answers1

1

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
Severin
  • 8,508
  • 14
  • 68
  • 117
  • I've found something similar: `jsonapi_resources :widgets` What sets the response to generate full/partial link paths? – vogomatix Jun 08 '17 at 13:03
  • I'm not sure what you want to achieve here. Could you update your question with a more precise description of what you are trying to do and how? – Severin Jun 08 '17 at 13:13
  • I want to change all links fields returned in responses from say `self: "http://192.168.0.1:3000/api/widgets/object_id"}` to `{self: "/api/widgets/object_id"}` – vogomatix Jun 08 '17 at 13:14