In my Rails 4 app, I have a API::V1::ClustersController
structured like so:
class Api::V1::ClustersController < ApplicationController
respond_to :json
def index
@clusters = Cluster.all
render json: @clusters
end
class
In my app/views/api/v1/clusters/index.json.jbuilder
view:
json.array!(@clusters) do |cluster|
json.extract! cluster, :id, :index
json.url cluster_url(cluster, format: :json)
end
In my routes:
namespace :api, defaults: { format: :json } do
namespace :v1 do
authenticated :user do
resources :clusters
end
end
end
Unfortunately, the following is the json output when I hit http://localhost:3000/api/v1/clusters.json
:
{
clusters: [
{
id: 1,
organization: null,
number: null,
name: "Roob Group",
created_at: "2014-07-16T17:41:09.214Z",
updated_at: "2014-07-16T17:41:09.214Z"
},
{
id: 2,
organization: null,
number: null,
name: "Lesch LLC",
created_at: "2014-07-16T17:41:09.302Z",
updated_at: "2014-07-16T17:41:09.302Z"
}
]
}
I don't know what else to do. Any help is appreciated.