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 of the models is indicated in Rails by annotating both models with a has_and_belongs_to_many association.
In order to store this new n:m relation, a new database table is needed. It is created in a migration.
Help on the required migration can be found in the this documentation.
There is also a generator which will 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 #
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 of the models is indicated in Rails by annotating both models with a
has_and_belongs_to_many
association.In order to store this new n:m relation, a new database table is needed. It is created in a migration. Help on the required migration can be found in the this documentation. There is also a generator which will produce join tables if 'JoinTable' is part of the name:
rails generate migration CreateJoinTableAuthorPaper author paper
Reminder: Migrations are stored indb/migrate
and are applied with therails db:migrate
command.Error
Estimated progress: 89% complete