title: saving and fetching hash in Mongoid Document
body: <p>I am creating a metrics hash using the following:</p>
  
  <pre><code>@metrics = Hash.new
  
  ...
  
  @metrics[:users][:year][:male] = ...
  @metrics[:users][:today][:male] = ...
  
  ...
  
  Metrics.new(:metrics =&gt; @metrics).save
  </code></pre>
  
  <p>and I have the following class:</p>
  
  <pre><code>class Metrics
    include Mongoid::Document
    include Mongoid::Timestamps
  
    field :metrics, :type =&gt; Hash
  
    attr_accessible :metrics
  
    ...
  
  end
  </code></pre>
  
  <p>To fetch this document, I have:</p>
  
  <pre><code>@metrics = Metrics.find(params[:id])
  @metrics = @metrics[:metrics]
  </code></pre>
  
  <p>In order to access these elements, I need to do:</p>
  
  <pre><code>@metrics['users']['year']['male']
  </code></pre>
  
  <p>Is there a way I can be consistent in how I access hash values but still storing data in mongo?</p>