Newbie to Ruby - would appreciate it enormously if somebody could help me with this.
In my create function, for a specific table, my foreign keys in that table are not visible for selection. However, at the time of writing to the database, they take one or the other values on these foreing keys. I carried out the validates_presence_of on these foreign keys and that started generating errors but it still did not show the foreign keys.
Example
Exam |---------< Exam_Subjects
--------| Subjects
Exam_id Exam_id (foreign- key) Subject_id Exam_Name Subject_id (foreign- key) Subject_Name Percent_of_questions
Difficulty_level_of_subjects
After generating the scaffolding, when I go to exam_subject/create screen, it only displays text-boxes to input Percent_of_questions and Difficulty_level_of_subjects. Its doesnt show Subject_id or Exam_id for input and takes default values to fill it.
What I need is drop downs for Exam_Name and Subject_Name.
I tried using the validates_presence_of Exam_id which actually resulted in generating an error but still no way of beinbg able to show the name fields for input.
I was going to write a code but think there must be some ruby method I can use to show all foreign keys for input? Is there one? Am I missing something?