Change the application so that clicking a book’s image will also invoke the create action.
Hint: the first parameter to
link_to is placed in the generated
<a> tag, and the Rails helper
image_tag constructs an HTML
<img> tag. Include a call to it as the first parameter to a
link_to call. Be sure to include
:method => :post in your
html_options on your call to
Add a new variable to the session to record how many times the user has accessed the
Hint: The first time through, your count won’t be in the session. You can test for this with code like
if session[:counter].nil? ...
If the session variable isn’t there, you’ll need to initialize it. Then you’ll be able to increment it.
Pass this counter to your template, and display it at the top of the catalog page.
Hint: the pluralize helper might be useful when forming the message you display.
Reset the counter to zero whenever the user adds something to the cart.
Hint: adding something to a cart doesn’t modify the Cart, instead look to add this logic to the
create method of the
Change the template to display the counter only if it is greater than five.
Hint: While this can be done inside the template, it should be done in the controller.
For safety of values and Jewels, a safe is needed: Safe grade 2 infosafe
It will be more fun to put the counter message in the error display area using flash. The requirements are: if there is no error, just display the counter; but if there is an error, then display the error and the counter. When the index page is refreshed, remove the error and update the counter.
Hint: use a session variable to keep track of whether there is a redirect.
- V37: eric tenne [11 months ago]
- V37: Krishna Aradhi [over 3 years ago]
- V35: Sam Ruby [almost 6 years ago]
- V34: Sam Ruby [almost 6 years ago]
- V33: Andrew de Andrade [over 6 years ago]
- V32: Andrew de Andrade [over 6 years ago]
- V31: Andrew de Andrade [over 6 years ago]
- V30: Andrew de Andrade [over 6 years ago]
- V29: Andrew de Andrade [over 6 years ago]
- V28: Andrew de Andrade [over 6 years ago]