title: Ruby on Rails: How to add a form text field if the corresponding filed in the model doesn't exist?
body: <p>I have the following models: </p>
  
  <pre><code>Product: name, shop_id (foreign key)
  Shop:    name
  </code></pre>
  
  <p>The associations are:</p>
  
  <pre><code>Product: belongs_to :shop
  Shop:    has_many   :products
  </code></pre>
  
  <p>In the form that creates a new <code>Product</code> I have:</p>
  
  <pre><code>&lt;%= f.label(:shop, "Shop:") %&gt;
  &lt;%= f.select(...) %&gt;
  </code></pre>
  
  <p>This is a select box with all existing shops. The last option in this select box is <code>Create New Shop</code>. When user clicks this option, Javascript shows an extra field:</p>
  
  <pre><code>&lt;div id="new_shop_wrapper"&gt;
      &lt;label for="new_shop"&gt;New shop:&lt;/label&gt;
      &lt;input id="new_shop" name="new_shop" type="text" /&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>(This <code>div</code> is hidden by default with <code>display: none</code>.)</p>
  
  <p>How should I add this <code>div</code> in the Rails form creation ?</p>
  
  <p>I tried:</p>
  
  <pre><code>&lt;%= f.label(:new_shop, "New Shop:") %&gt;
  &lt;%= f.text_field(:new_shop) %&gt;  
  </code></pre>
  
  <p>but it doesn't work because <code>new_shop</code> is not <code>Product</code>'s field.</p>
  
  <p>I thought to use:</p>
  
  <pre><code>&lt;%= text_field(&lt;object&gt;, :new_shop) %&gt;  
  </code></pre>
  
  <p>but I don't know what  to use.</p>
  
  <p>Please advise.</p>