Open dmastylo opened 9 years ago
What happens if you do:
node :team do |player|
team = player.team
{ :id => team.id, :name => team.name }
end
does that print out as expected? or how about:
child :team => :team do
attributes :id
end
anything?
Looks like I'm running into even more issues. I tried adding extra attributes to the file but I'm still getting only the old ones??
{
"id": 1,
"created_at": "2015-05-13T00:52:34.307-04:00",
"game": {
"id": 1,
"name": "Game #<#<Class:0x007fe14c5aafe8>:0x007fe14c5aab10>",
"starts_at": "2015-05-17T00:52:34.232-04:00",
"ends_at": "2015-05-17T03:52:34.232-04:00",
"buy_in_price": 19,
"max_players": 38,
"in_progress": false,
"players": [
{
"player": {
"id": 1,
"username": "person33"
}
}
],
"teams": [
{
"team": {
"id": 1,
"name": "815",
"score": 0,
"player_count": 1
}
},
{
"team": {
"id": 2,
"name": "754",
"score": 0,
"player_count": 0
}
},
{
"team": {
"id": 3,
"name": "416",
"score": 0,
"player_count": 0
}
},
{
"team": {
"id": 4,
"name": "736",
"score": 0,
"player_count": 0
}
}
]
}
}
I believe this might have something to do with namespacing (I have an API::V1 and API::V2 namespace), but this is the first file where I've encountered the issue. My api/v1/games/show
and api/v2/games/show
have very different setups and they render correctly.
Even weirder... When I do
node :team do |player|
team = player.team
{ :id => team.id, :name => team.name }
end
If team is nil (the player doesn't have a team) then an exception is thrown that we're trying to call .id on nil, so it's obviously going through the right file... but the output is still not showing it when the team does exist.
I'm extremely stumped. This isn't happening anywhere else but this file.
Okay, so I just tried doing it manually via cURL, everything worked as expected, all the nodes that I put in there worked. Then when I ran rspec, everything passes.
I cannot make this up. Have been pulling my hair out for 3 hours on this. Some sort of weird caching issue or something?? Christ.
Sorry about this, that does sound frustrating...is everything working now?
@nesquena No need to apologize, not your fault. As far as I know everything is working. I don't think this is a rabl issue unless the library is doing some caching under the hood. Really bizarre.
My rspec code:
Rsepc result:
As you can see, a team exists for the player in question, but is not being printed in the JSON. On the flip-side, the game node is being printed just fine.
Player/show code:
rabl response
I have absolutely no idea what's wrong.