To Examples

Hospital2 Example

Source code file: Hospital2/app/views/contact_info/show.html.erb:

<h1>Hospital2 Example<h2>

<h2>Patient Table</h2>

<table>
<tr> 
  <th>Patient Name</th>
  <th>Doctor Name</th>
  <th>Doctor Phone</th>
</tr>

<% @patients.each do |pat| %>
<tr>
  <td><%= pat.first_name %> <%= pat.last_name %></td>
  <td><%= pat.doctor.name %></td>
  <td><%= pat.doctor.phone_num %></td>
</tr>
<% end %>
</table>

<h2>Doctor List</h2>

<ol>
  <% @doctors.each do |doc| %>
  <li><%= doc.name %>
  <ol>
    <% doc.patients.each do |pat| %>
      <li>
        <%= pat.last_name %>, 
        <%= pat.first_name %>; 
        <%= pat.phone_num %>
      </li>
    <% end %>
  </ol>
  <% end %>
</ol>