p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Beginning Ruby on Rails (http://p2p.wrox.com/forumdisplay.php?f=289)
-   -   Problem with ch09 "Creating a filter" example. (http://p2p.wrox.com/showthread.php?t=52863)

nick_rasband@byu.net January 17th, 2007 09:07 PM

Problem with ch09 "Creating a filter" example.
On p, 273 there is a "Try It Out" exercise for creating an online filter. I have built everything correctly, and even used the downloaded code, but I can't get the application to display the "now" action when it isn't business hours. Plus, there isn't a "game" action, so I don't understand why step 11 tells you to navigate to http://localhost:3000/play/game. Nevertheless, it works and displays not.rhtml if the time is between 9:00am and 5:00pm as it should, but I changed my system clock to 7:00pm and navigated to http://localhost:3000/play/game and it told me that "no action responded to game". I tried restarting the WEBrick server a couple of times and even tried clearing my cache and cookies, but I think that the example is essentially flawed. Any help would be greatly appreciated.


DEMITTON February 13th, 2007 12:53 PM

The action which do not work has a very bad chosen name: "not".
Ther is no "game" action, only a "game" application
with two actions, "now" and "not".

Please use another name for "not", like "noplaynow".
You have to:
1) change the name not in the "play" controller (even if the action
has an empty body)
2) change the call in the controller after :except =>
3) create a view file in app/views/play called "noplaynow.rhtml".


divnavoda March 26th, 2007 11:06 AM


you've made a good observation about the lack of 'game' action. Take it a step further and ask, so what actions are available? You will realize that the navigate to http://localhost:3000/play/game is a typo. It should have been http://localhost:3000/play/now.

Also, check the address line in the accompanying figures, they show the real addresses (no typos there, I think at least).

There is nothing wrong with the application; it works as supposed, you do not need to do any tweaking.

Also, when testing it, you do not need to change system time, it takes considerably longer to change system time back and forth then changing the values of the time range inside the code itself. :)

By the way, the if statement inside the check_time method looks better this way:

(9..17).include? Time.now.hour


All times are GMT -4. The time now is 04:21 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.