This is what I am trying to do. I have a user profile page that uses a user model and retrieves the data from the backend via ember data. I can see that ember requests /users/1 and I am able to use the data in the template associated with this route. So far so good.
On the profile page I also want it to load the photos that the user has uploaded. On the backend I have setup the request /users/1/photos. This is where I am getting confused. If I have understood this correctly I should use a nested route to get ember to request this data?
I will also have several links on the profile template to change the sorting and show other photos. So, on the profile page I would have a link to update the default photos content and request /users/1/photos?sort=popular from the backend. I would also have pagination requests like /users/1/photos?sort=popular&offset=20&limit=20. Old school wise this would be a simple ajax update to a div on the page with different params. As I will also be adding sections to the profile page where photos do not belong to the user I can’t always assume that photos will belong to the user model like photo comments would.
Would appreciate any pointers to get me started in the right direction. I have read a few tutorials but I can’t seem to figure out how to make it work in my use case.
OK, so I have done more reading.
I will try to illustrate below what I am trying to do:
Url structure:
/username → loads a main template with the user model attached to it. Also loads photos into the main templates outlet.
/username/about → loads main template as before and fills outlet with about info.
/username/posts → loads main template as before and fills outlet with posts.
Now what I am having difficulties doing is how to by default load the photos content when I am at the root url.
This works but each time I go to username it redirects to /username/photos. I want to display the photos route in the profile route. Also my /:username path variable doesn’t really seem to work properly as I get redirected to /<App.User:ember248:username>/photos. I am sure that I am missing something! There must be a better way to setup the route /:username as it doesn’t work with the linkto helper either.