Last time, we setup our route, and now if you go to: http://localhost/index.cfm/ads/3, you won’t get an error. But, just like on Page 63 of Head First Rails, the ads are blank and the page is kind of boring — There’s no data.
First, we need to fix our controller at /controllers/Ads.cfc. Make sure your show function looks like:
When Wheels created the model, it automatically adds the findByKey method. All we have to do is tell it which key we want, and params.key has the key value!
We still need to fix /views/ads/show.cfm to display the data. Change this file to:
Pretty neat. Just put the values in the view and wrap it up in a <cfoutput> tag! Wheels handles the hard part of getting the data from the database into the model.
Go back to: http://localhost/index.cfm/ads/3, and you’ll see that the data is now being correctly displayed.