swt2-intro-exercise / rails-exercise-22-janiswehen

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

Edit paper page should allow to select paper authors from a multiple select box #18

Open swt2public opened 2 years ago

swt2public commented 2 years ago

Scenario

Given a paper When a user visits the paper's edit page Then it should have a single multiple select box

Hints

Make sure the n:m relation of papers and authors works in your automated tests, i.e. models are annotated with has_and_belongs_to_many and a db migration for the new join table was created and run.

On a paper's edit page, it should be possible to add multiple authors. An HTML multiple select element allows this. Rails' select helper in combination with the 'options_from_collection_for_select' helper can be used to create the required HTML element:

<%= form.select 'author_ids',
  options_from_collection_for_select(Author.all, :id, :name, paper.author_ids),
  {},
  multiple: true, size: 10 %>

Notice the usage of author_ids in the code snippet. These are the ids transmitted by the form to the server.

The paper controller must be able to deal with the additional author information that is passed by the new select element to save the changes. Make sure that you have "permitted" the parameters for passing the author ids to the paper controller (function paper_params) using :author_ids => [].

Error

Expected to find css "select[multiple]" 1 time but there were no matches

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