Hi All,

I am new to Ruby and trying to develop a simple web application. Currently, I have two tables namely products and users.

Products table has the following field:

id(int), name(string), quantity(int), Price(float)

Users table has the following field:
id(int), name(string), balance(float)

I can display the data from products table but not users table.

Here are the codes from index.rhtml under C:\products\app\views\product directory:

<% Product.find(:all).each do |product| %>
<table border="1">
<tr>
<td width="40%"><p align="center"><i><b>Product</b></i></td>
<td width="20%"><p align="center"><i><b>Price</b></i></td>
<td width="20%"><p align="center"><i><b>Quantity</b></i></td>
<td width="20%"><p align="center"><i><b>Add to cart</b></i></td>
</tr>
<tr>
<td width="40%"><p align="center"><i><b><%= product.name %></b></i></td>
<td width="20%"><p align="center"><i><b><%= product.Price %></b></i></td>
<td width="20%"><p align="center"><i><b><%=product.stock%> </b></i></td>
</tr>
<% end %>

Can anyone show me how to display data from users table into a drop down list box? Also, do we need to create a foreign key to link up two tables?

Are all the tables in Ruby must have a relationship with each other?

Please advice.

Thanks.

Cheers,
Fung