I am a complete rookie in rails development so expect the worst. Up until now I have read a lot about this but I am still unable to find out what I did wrong.

I have difficulties finding the right way to create a model and migration that would enable the relationship described in the model below.

![This is what I am trying to accomplish](https://i.stack.imgur.com/WNUgS.jpg)

Right now this is my migration:

```
    class CreateCoaches < ActiveRecord::Migration
  def change
    create_table :coaches do |t|
      t.string :first_name
      t.string :last_name
      t.string :email
      t.timestamps
    end

    create_table :pupils do |t|
      t.string :first_name
      t.string :last_name
      t.string :email
      t.belongs_to :coach
      t.timestamps
    end

        create_table :talks do |t|
      t.belongs_to :coach

      t.belongs_to :pupil
      t.datetime :talk_date
      t.timestamps
    end
  end
end

```

And this is the models:

```
class Coach < ActiveRecord::Base
  has_many :talks
  has_many :pupils, through: :talks
  has_many :pupils
end

class Patient < ActiveRecord::Base
  has_many :talks
  belongs_to :coach
  has_many :coaches, through: :appointments

end

class Talk < ActiveRecord::Base
  belongs_to :pupil
  belongs_to :coach
end

```

This is the rspec test I am trying to execute (I hope it does not make your eyes bleed...)

```
require 'spec_helper'

describe Coach do
  before(:each) do
    @coach = Coach.create!(first_name: "Förnamn", last_name: "Efternamn")
  end

  it "creates a Coach" do
    Coach.create!(first_name: "Andy", last_name: "Lindeman")

    expect(Coach.find_by_first_name("Andy").first_name).to eq("Andy")

  end   

  it "creates a Coach and a pupil" do

    @coach.pupils << Pupil.create!(first_name:"Donald", last_name:"Duck")
    expect(@coach.pupils[0].first_name).to eq "Donald"

  end
end

```

And the error: 

Failure/Error: @coach.pupils << Pupil.create!(first\_name:"Donald", last\_name:"Duck")
 LoadError:
 Unable to autoload constant Pupil, expected /home/elgrego/Projects/Coachen/app/models/pupil.rb to define it

Regards 
Elgrego