|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
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 |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Ruby Programming > How to display data from 2 tables that are independent of each other |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|