I have a “Post” model in my Ember CLI app with two routes:
- An “index” route (for a list of all of the posts)
- A “view” route (to view a single post).
My index route calls “/posts” and pulls in the JSON data that looks like this:
{
"posts": [
{
"id": 1,
"title": "Post One"
},
{
"id": 2,
"title": "Post Two"
},
{
"id": 3,
"title": "Post Three"
}
]
}
As I understand the REST Adapter, my view route should call /posts/[id], which looks like this:
{
"post": {
"id": 1,
"title": "Post One",
"body": "<p>Lorem ipsum dolor sit amet.<\/p>"
}
}
However, when I use {{body}}
in my view template, it outputs undefined
. When I add the body field to my /posts data it shows up correctly.
Is there a reason why my /posts/[id] data isn’t getting used for my view page, but it’s using the /posts/ data instead?