The has_many relationship between the actor and booking tables lets you retrieve
all of the booking objects for each actor, and the various belongs_to relationships in the
booking model allow you to retrieve the details of each booking. You could also add
has_many :bookings relationships to the room and project models, but since you won??™t
use them in the controller, they are omitted.
At this point, you have a database with data in it and a Rails application with a few
models. Of course, models are just one-third of an MVC application, so let??™s create a controller
next.
CHAPTER 5 n CONNECTING YOUR REPORTS TO THE WORLD 84
Creating the Controller for the Web Report
The controller will respond to actions of the user by taking data from the model and presenting
it via your views .The controller is named home, since you will have just one page.
Create the app/controllers/home_controller.rb file with the code shown in Listing 5-6.
Listing 5-6. Home Controller for the Web Report (app/controllers/home_controller.
Pages:
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138