title: Ruby/Rails - Can't access JSON object attributes directly in controller
body: <p>I am setting up an API.</p>
  
  <p>The client (using HTTParty) posts this to the API:</p>
  
  <pre><code>{:body =&gt; 
         {
          :product=&gt; {:description=&gt;"some text", :cost =&gt; "11.99"}, 
          :brand=&gt;   {:name=&gt;"BrandName", :etc =&gt;"hey"}
         }
  }
  </code></pre>
  
  <p>The server/api receives the post.
  Now, if I access <code>params[:brand]</code> I get:</p>
  
  <pre><code>{"name"=&gt;"BrandName", "etc" =&gt;"hey"}
  </code></pre>
  
  <p>If I do this:</p>
  
  <pre><code>Brand.new(params[:brand])
  </code></pre>
  
  <p>Then I get a new Brand object with the "name" and "etc" attributes populated correctly.</p>
  
  <p>However, if I try to access <code>params[:brand][:name]</code>, I just get <code>nil</code></p>
  
  <p>Any ideas?</p>
  
  <p>Thanks.</p>