title: Ruby on Rails: Association model, do I need controller to save data?
body: <p>I'm new to Ruby on Rails, maybe someone can help me.</p>
  
  <p>I have an association, I was wondering if I need a controller to save data into the database table?</p>
  
  <p>I have <strong>user.rb</strong> model</p>
  
  <pre><code>has_many :businesses
  </code></pre>
  
  <p>I have <strong>business.rb</strong> model</p>
  
  <pre><code>belongs_to :user
  </code></pre>
  
  <p>I have this in the business migration file</p>
  
  <pre><code>class CreateBusinesses &lt; ActiveRecord::Migration
    def change
      create_table :businesses do |t|
        t.integer :user_id
        t.string :name
        t.string :street
        t.string :state
        t.string :city
        t.integer :zip
  
        t.timestamps
      end
    end
  end
  </code></pre>
  
  <p>I'm wondering if I need to create a controller file to save data into business table? </p>
  
  <p>I have something like this in <code>views/users/profile.html.erb</code> page</p>
  
  <pre><code>&lt;%= form_for(@user) do |f| %&gt;
    &lt;div class="field"&gt;
      &lt;%= f.label :company_name %&gt;
      &lt;%= f.text_field :company_name %&gt;
    &lt;/div&gt;
    &lt;div class="actions"&gt;
      &lt;%= f.submit %&gt;
    &lt;/div&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>How do I set this form so that I can save my :company_name into business's table :name as well, and so I can also add :street, :state, etc... to this form?</p>
  
  <p>I only generated a model, and there is no controller for businesses yet.</p>
  
  <p>Thanks!</p>