title: ruby on rails - after establishing many to many connection - how do I display data
body: <p>I have established many to many relation with the help of this site.<br>
  I have added has_and_belongs_to_many in the model<br>
  Now I want to display data from that object on the screen<br>
  I assume I should do it in the html.erb<br>
  lets say that I want it on the index form and in the edit/new form  </p>
  
  <p>how can I present that?
  thanks.</p>
  
  <p>EDIT:<br>
  I have two objects :<br>
  i.e. person and states - A person can have many states)<br>
  I want to have a screen where I could present all the states of the person and another screen where I can add him another states.<br>
  as I mentioned I created rb scripts like this (for both)</p>
  
  <pre><code>class CreateStates &lt; ActiveRecord::Migration
  def change
    create_table :states do |t|
      t.string :name
      t.timestamps
    end
   end
  end
  </code></pre>
  
  <p>and a join table </p>
  
  <pre><code>def up
    create_table 'persons_states', :id =&gt; false do |t|
    t.integer :persons_id
    t.integer :states_id
  end
  </code></pre>
  
  <p>end
  and in the model added  has_and_belongs_to_many :ingredients</p>
  
  <p>How do I update my code of ther gui?
  thank</p>