Display field from related table [message #298] |
Tue, 03 October 2006 21:35 |
Acharn
Messages: 6 Registered: August 2006 Location: Thailand
|
Junior Member |
|
|
I've been using the example of the Ruby on Rails Cookbook to try to get a handle on using your framework, and I've hit on a snag. The database contains two tables: categories and recipes. Categories has two fields: id and name. Recipes has 6 fields: id, title, description, date, instructions, and category_id. Category_id is a foreign key to the categories table.
I've managed to get the basic menu and process scripts working, but in the screens which display data from the recipes table I want to show the name of the category, not its index number. I figured I could examine your solutions and chose the Classrooms prototype. The screen listing Lessons looked good, because you display the name of the teacher, rather than the teacher_id. But when I examine lesson_list.php and the associated crs_lesson.list.screen.inc I don't find any clue. The way the SQL is constructed is helpful on its own, but I expected some reference to the crs_teacher table to retrieve the name field.
The teacher's name displayed in the lesson_list screen is a nicely formatted string made from the three fields crs_teacher.title, crs_teacher.first_name, and crs_teacher.last_name. How did you do it?
Roger
|
|
|