title: Chef, ruby hashes and templates
body: <p>I know this is more a <code>ruby</code> question than <code>chef</code>, but...</p>
  
  <p>I have some attributes like:</p>
  
  <pre><code>default['my_cookbook']['some_namespace1']['some_attribute1'] = 'some_value1'
  default['my_cookbook']['some_namespace1']['some_attribute2'] = 'some_value2'
  default['my_cookbook']['some_namespace1']['some_attribute2'] = 'some_value3'
  ...
  default['my_cookbook']['some_namespace2']['some_attribute1'] = 'some_value1'
  default['my_cookbook']['some_namespace2']['some_attribute2'] = 'some_value2'
  default['my_cookbook']['some_namespace2']['some_attribute2'] = 'some_value3'
  ...
  </code></pre>
  
  <p>On the other hand, I am creating a template resource like this:</p>
  
  <pre><code>template 'template_name' do
    source 'template_source.erb'
    variables (
      my_namespace_1: node['my_cookbook']['some_namespace1'],
      my_namespace_2: node['my_cookbook']['some_namespace2']
    )
  end
  </code></pre>
  
  <p>Then in the <code>template_source.erb</code> I try:</p>
  
  <pre><code>...
  &lt;%= @my_namespace_1['some_attribute1'] %&gt; #=&gt; 'some_value1'
  ...
  </code></pre>
  
  <p>However when I run Kitchen I get this, instead of <code>'some_value1'</code>:</p>
  
  <pre><code>Chef::Mixin::Template::TemplateError
  ------------------------------------
  undefined method `[]' for nil:NilClass
  </code></pre>
  
  <p>How should I send the template variable to use it this way?</p>