I am attempting to create a custom JSON response in Jbuilder. The scheme is pretty simple:
json.name = @locations.name
json.description = @locations.description
However, I am getting a Missing Template error because I have namespaced my route and cannot use the current index.son.jbuilder. Currently, my route is setup as
Rails.application.routes.draw do
namespace :api, defaults: {format: 'json'} do
namespace :v1 do
resources :locations
end
end
root 'locations#index'
resources :locations
...
And my controller is pretty simple:
module Api
module V1
class LocationsController < ApplicationController
respond_to :json
def index
@locations = Location.all
end
end
end
end
It does not currently use my index.son.jbuilder. I have attempted to create a new json file with matches the naming scheme api.v1.index.son.jbuilder but the error persists. What am I missing?
Aucun commentaire:
Enregistrer un commentaire