title: Rails test for key in hstore column
body: <p>I have a Rails 4 app where the model <code>Vehicle</code> has an hstore column called <code>data</code>.  The app is also using <code>gem 'acts_as_tenant'</code>. The model <code>Tenant</code> also has an hstore column called <code>data</code>.</p>
  
  <p>What I'm doing is storing user defined fields in Tenant for the Vehicle table.  In other words if the Tenant data (hstore) column contains 'color', then I want every Vehicle to have that same key in their data (hstore) column.</p>
  
  <p>This is the code for the Vehicle form:</p>
  
  <pre><code>   &lt;% if current_tenant.data.present? %&gt;
          &lt;%= f.simple_fields_for :data do |d| %&gt;
              &lt;% current_tenant.data.each do |key, value| unless ???????@vehicle.data%&gt;
                  &lt;div class="row"&gt;
                    &lt;p class='col-md-3'&gt;
                      &lt;%= text_field_tag key, key, :class =&gt; 'text_field dynamicAttributeName' %&gt;
                    &lt;/p&gt;
                    &lt;p class='col-md-3'&gt;
                      &lt;%= d.text_field key, :class =&gt; 'text_field', :value =&gt; value %&gt;
                    &lt;/p&gt;
                    &lt;p class='col-md-1'&gt;
                      &lt;a herf='#' class='btn removeRow'&gt;X&lt;/a&gt;
                    &lt;/p&gt;
                  &lt;/div&gt;
              &lt;% end %&gt;
          &lt;%- end -%&gt;
      &lt;% end %&gt;
  
      &lt;% if @vehicle.data.present? %&gt;
          &lt;%= f.simple_fields_for :data do |d| %&gt;
              &lt;% @vehicle.data.each do |key, value| %&gt;
                  &lt;div class="row"&gt;
                    &lt;p class='col-md-3'&gt;
                      &lt;%= text_field_tag key, key, :class =&gt; 'text_field dynamicAttributeName' %&gt;
                    &lt;/p&gt;
                    &lt;p class='col-md-3'&gt;
                      &lt;%= d.text_field key, :class =&gt; 'text_field', :value =&gt; value %&gt;
                    &lt;/p&gt;
                    &lt;p class='col-md-1'&gt;
                      &lt;a herf='#' class='btn removeRow'&gt;X&lt;/a&gt;
                    &lt;/p&gt;
                  &lt;/div&gt;
              &lt;% end %&gt;
          &lt;%- end -%&gt;
      &lt;% end %&gt; 
  </code></pre>
  
  <p>My issue is the line <code>&lt;% current_tenant.data.each do |key, value| unless ???????</code></p>
  
  <p>I don't want to add the same key twice. So, if the Vehicle data field already has <code>color</code>, I don't want to add it again.</p>
  
  <p>How do I test the Vehicle.data field to see if it has a key equal to the <code>current_tenant.data.each do |key, value|</code>.</p>
  
  <p>Thanks for the help!!!</p>