I am very new to Ruby, I get the following error:
Gem_original_require ': ./helpers/navigation.rb:28: Strange Number List for Hash (Syntax Errors)
Any help appreciated ...
Module Sinatra :: Navigation Def Navigation @ Navigation NAV = {Primary [0] = {: Title = & gt; "Shader" ,: Active = & gt; Wrong: children = & gt; {{: Title = & gt; "Paneer" ,: Active => Wrong}, {: title = & gt; "Ham",: active => False}}}, primary [1] = {: title = & gt; "Gorgonzola",: Active => Wrong: children = & gt; {{: Title = & gt; "What is cheese?" ,: Active => Wrong}, {: title = & gt; "What cheesy" ,: active => Wrong}, {: title = & gt; "What does cheese tell us?",: Active => Wrong: children = & gt; {{: Title = & gt; "Chasas" ,: Active => Wrong}, {: title = & gt; "The effect of various things / characteristics for cheese in relation to the results of CSE",: Active => False}}}}}}
Ruby is used to describe a Hashp in curly braces from pairs of keys and values Together, square brackets are used to describe the array. Your child's attribute does not have a key-value-pair, so you have made an array instead of a hash.
Therefore
of: children = & gt; {{: Title = & gt; "Paneer" ,: Active => Wrong}, {: title = & gt; "Ham",: active => False}}
please:
: children => [{: Title = & gt; "Paneer" ,: Active => Wrong}, {: title = & gt; "Ham",: active => False}]
and for other events of
: children
.I am also not convinced that receiving
primary [0] =
is considered, but it almost certainly does not do what you want to do it. What it does, it sets the first element of theprimary
(which means that an array of primary names exists before that assignment) and then returns that element back to it.If you want to structure your hash so that it can be accessed like
nav [: primary] [0] [: children] [0]
, you do this Will be:nav = {: primary => [{: Title = & gt; "Shader" ,: Active = & gt; Wrong: children = & gt; [{: Title = & gt; "Paneer" ,: Active => Wrong}, {: title = & gt; "Ham",: active => Wrong}}}, {: title = & gt; "Gorgonzola", # ...}]}
Also note that the line before
nav
is specified by the line@navigation
Nothing.
Comments
Post a Comment