Lab – Adding category

Try to allow assigning one and only one category to each job.

steps:

  1. category model
  2. category controller
  3. form for category
  4. associate with job
  5. set category in job

selecting the category as a list instead of inputing the number.

f.collection_select :category_id, Category.all, :id, :title, prompt: 'Choose a category'

Full source code can be found in the course github project: makzan/ruby-on-rails-course-2013.

What’s next? We’re going to take a look at “Uploading files”.

overlaied image when clicked on thumbnail

Makzan | Ruby on rails 101 | Table of Content