Take a look at the image below to get an idea of how it should appear.
In my Ruby on Rails database, I have a table named sauces.
Here are the fields in the sauces table:
- id
- name
- description
- picture
This is the CSS code:
#container{width:950px;height:800px;}
#title{this_is:irrelevant;}
#sauce_picture{bla bla}
#sauce_name{bla bla}
#sauce_splatter{background-image:url("someimage.png")}
HTML Code:
<html>
<body>
<div id="container>
<div id="title><h1>SAUCES</h1></div>
<div id="sauce_picture><img src="somepic.png/></div>
<div id="sauce_name><h2>Sauce 1</h2></div>
<div id="sauce_splatter>
<p>Sauce Description Goes Here</p>
</div>
</div>
</body>
</html>
I have 6 records in the Rails database table and each field is filled. When the page loads, I want the content to display the information from record number one (<img src="somepic.png/>
, <h2>Sauce 1</h2>
,
<p>Sauce Description Goes Here</p>
) because the count starts at one.
I'm not sure how to set it up so that when the right arrow key is pressed, the id increments to two and displays the details of record number 2 (id=2).
Lastly, I need to figure out how to disable the left arrow link when id=1 (first record) and disable the right arrow link when the last record is reached. This functionality can be achieved through changing elements with jQuery, but integrating Rails and jQuery is something I need guidance on.
This approach will eliminate the need to modify any code when adding new sauces to the database table in the future, which aligns perfectly with MVC principles.
Thank you!