In the show page I was trying to figure out how to print the members of the team. And after 2 days, I finally...figured it out. My solution is probably pretty crappy, but whatever. So here are ALL the things that needed to be done:
Turns out that in my _team partial for jbuilder, I needed to also put the team members in the json I got back. So I added json.set! :members, team.members
My controllers I think were also not rendering the right stuff. In the show for Teams for example, I was doing render :show, but I think it needed to be render "api/teams/show". Actually, I'm not sure how necessary that is, because it seems like both would get my jbuilder file. Gotta investigate that more.
The BIGGEST annoyance was in the team_show.jsx file. I tried to get .members, but it would error out cause the ajax call hadn't been made yet. So then I was trying to say if team.name, then map members, but that wasn't working either. Turns out that there are 2 ajax calls (one to receive all teams for the sidebar, and one to receive the team for the show page), and the first time team is defined, but not members yet. So I had to do a nested if statement.
I had to do a componentWillReceiveProps because when I was clicking to new pages, the ajax call wouldn't fire. With componentWillReceiveProps, it does now.
In the show page I was trying to figure out how to print the members of the team. And after 2 days, I finally...figured it out. My solution is probably pretty crappy, but whatever. So here are ALL the things that needed to be done:
Turns out that in my _team partial for jbuilder, I needed to also put the team members in the json I got back. So I added
json.set! :members, team.members
My controllers I think were also not rendering the right stuff. In the show for Teams for example, I was doing
render :show
, but I think it needed to berender "api/teams/show"
. Actually, I'm not sure how necessary that is, because it seems like both would get my jbuilder file. Gotta investigate that more.The BIGGEST annoyance was in the team_show.jsx file. I tried to get .members, but it would error out cause the ajax call hadn't been made yet. So then I was trying to say if team.name, then map members, but that wasn't working either. Turns out that there are 2 ajax calls (one to receive all teams for the sidebar, and one to receive the team for the show page), and the first time team is defined, but not members yet. So I had to do a nested if statement.
I had to do a componentWillReceiveProps because when I was clicking to new pages, the ajax call wouldn't fire. With componentWillReceiveProps, it does now.