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 class Guest < ApplicationRecord
def full_name
"#{first_name} #{last_name}"
end
end end

View File

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