Display list of guests

This commit is contained in:
Manuel Bustillo 2024-07-11 20:13:22 +02:00
parent f66957dd3d
commit 946cd959e2
2 changed files with 18 additions and 4 deletions

View File

@ -1,2 +1,5 @@
class Guest < ApplicationRecord
def full_name
"#{first_name} #{last_name}"
end
end

View File

@ -3,12 +3,23 @@
<h1>Guests</h1>
<div id="guests">
<table>
<tr>
<th>Name</th>
<th>Email</th>
<th>Phone</th>
<th colspan="2"></th>
</tr>
<% @guests.each do |guest| %>
<%= render guest %>
<p>
<%= link_to "Show this guest", guest %>
</p>
<tr>
<td><%= guest.full_name %></td>
<td><%= guest.email %></td>
<td><%= guest.phone %></td>
<td><%= link_to "Show", guest %></td>
<td><%= link_to "Edit", edit_guest_path(guest) %></td>
</tr>
<% end %>
</table>
</div>
<%= link_to "New guest", new_guest_path %>