Today we began "Phase 2" of the Job Listing Project, which involved Steps 6 through 8.
Step 6 involved using the .order method and the "case...when...else..." statement to sort job listing by different metrics. This was fairly simple as the instructor has given sufficient hints in the slides.
Step 7 involved using the Carrierwave gem to upload PDF-version resumes. Installing the gem and get the uploaded to work was the easy part, but establishing the relationship between Resume, Job, and User was challenging (details below).
Step 8 involved adding the number of resume applied to a certain job posting to the admin view page, as well as making this number a live HTML link connecting to the resume index for view and download. This required good grasp of rake routes to ensure that I got the right paths set for links and was quite challenging as well.
I got quite stuck during the part which needed to establish relationship between the three models, and even with the help of the TA it took me quite a while to realize what I missed. I need to better understand how to establish relationships between different models.
I learned two very important lessons today. One is that when building a form to enter information for a second-layer model, the code @MODEL isn't sufficient, but needed to include [:MODEL1, @MODEL2]. For instance, in the second line below, resume is under job, and a form to upload resume would require square brackets around to establish a relationship with job:
Another important lessons I learned today is that in a three-model situation, when uploading a resume, we need to also set which job and user the resume belonged to. This is established by the following under the `resumes_controller.rb':
Essentially, if in the model there is a "belongs_to" relationship from one model to another, this needs also to be reflected in the controller.
Today was overall productive as I was able to complete the assignment using Google (StackOverflow), the instructor's PDF instructions, as well as the TA's assistance. But I feel that I still lack understanding of the Ruby language and will begin to spend more time learning the fundamental aspects this week.