swt2-intro-exercise / rails-exercise-22-navetis

rails-exercise-22-navetis created by GitHub Classroom
MIT License
0 stars 0 forks source link

Paper should have and belong to many authors #12

Open swt2public opened 2 years ago

swt2public commented 2 years ago

Scenario

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

Hints

A paper can have many authors and 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: guide. There is a generator which can produce join tables if 'JoinTable' is part of the name:

rails generate migration CreateJoinTableAuthorPaper author paper

To test if such a relation exists, you can test whether a paper has an empty list of authors.

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

Error

Got NoMethodError: undefined method `authors' for #

37 exercise tests have passed. There are 44 in total. You will solve multiple at once towards the end.

swt2public commented 2 years ago

Sorry, it's not working for me yet:

Scenario

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

Error

Got NoMethodError: undefined method `authors' for #

If you have problems solving this task, please don't hesitate to contact the teaching team!