i have a hash of hashes in rails, like :
{"round"=>1, "turn"=>1, "attacker_hp"=>11220, "defender_hp"=>205, "damage"=>95, "attacker"=>#<User id: 2, email:...>}, {"round"=>1, "turn"=>2, "attacker_hp"=>11220, "defender_hp"=>205, "damage"=>95, "attacker"=>#<User id: 1, email:...>} ...
So, as you can see, in this hash, there is a number of hashes that represent a combat turn. There is also a hash entry that contains a full object.attributes in it (the 'attacker' entry').
Now, i want to represent that using JQuery in Rails. I've tried to use something like :
var combat_stats = <%= array_or_string_for_javascript(@combat) %>;
to get the values in Javascript. This works, but there is an important problem. It seems that it creates an array of strings. Thus, the internal hashes are now strings, which makes it impossible for me to parse in javascript.
My question is, how can i access values like :
turn['attacker']['name'] or turn['attacker_hp']
as i could easily do in a @combat.each loop inside Rails view ?