swt2-intro-exercise / rails-exercise-19-Jasperhino

rails-exercise-19-Jasperhino created by GitHub Classroom
MIT License
0 stars 0 forks source link

Paper should have and belong to many authors #15

Closed swt2public closed 5 years ago

swt2public commented 5 years ago

Scenario

Given a paper Then it should have an empty list of authors

Hints

A paper can have many authors. An author can write many papers. This relationship is indicated in Rails by annotating both models (i.e. the Author and Paper) with a has_and_belongs_to_many association.

To store this n:m relation, create a new database table in a migration. Here is documentation on the required migration. There is a generator which can produce join tables if 'JoinTable' is part of the name:

rails generate migration CreateJoinTableAuthorPaper author paper

Reminder: Migrations are stored in db/migrate and are applied with the rails db:migrate command.

Error

Got NoMethodError: undefined method `authors' for #

38/44 exercise tests have passed