title: How to access data through many_to_many relation?
body: <p>How do I Access data through this Many_to_Many relation?</p>
  
  <p>Here are my database creations:</p>
  
  <p>The "Useres":</p>
  
  <pre><code>class CreateSubgroups &lt; ActiveRecord::Migration
    def change
      create_table :subgroups do |t|
        t.string :name
        t.belongs_to :group
  
        t.timestamps
      end
    end
  end
  </code></pre>
  
  <p>The relationship:</p>
  
  <pre><code>class CreateRtimespans &lt; ActiveRecord::Migration
    def change
          create_table :rtimespans do |t|
              t.belongs_to :subgroup_id
              t.belongs_to :timespan_id
          end
      end 
  end
  </code></pre>
  
  <p>The Used:</p>
  
  <pre><code>class CreateTimespans &lt; ActiveRecord::Migration
    def change
      create_table    :timespans do |t|
        t.string      :name
        t.text        :descrition
        t.integer     :start_h
        t.integer     :start_m
        t.integer     :end_h
        t.integer     :end_m
      end
    end
  end
  </code></pre>
  
  <p>How do I for example access the names of all timespans, that belong to one subgroup?
  And vis versa, how can I show, which subgroups use a specific timespan?</p>