diff --git a/app/controllers/guests_controller.rb b/app/controllers/guests_controller.rb
new file mode 100644
index 0000000..bc2a451
--- /dev/null
+++ b/app/controllers/guests_controller.rb
@@ -0,0 +1,70 @@
+class GuestsController < ApplicationController
+ before_action :set_guest, only: %i[ show edit update destroy ]
+
+ # GET /guests or /guests.json
+ def index
+ @guests = Guest.all
+ end
+
+ # GET /guests/1 or /guests/1.json
+ def show
+ end
+
+ # GET /guests/new
+ def new
+ @guest = Guest.new
+ end
+
+ # GET /guests/1/edit
+ def edit
+ end
+
+ # POST /guests or /guests.json
+ def create
+ @guest = Guest.new(guest_params)
+
+ respond_to do |format|
+ if @guest.save
+ format.html { redirect_to guest_url(@guest), notice: "Guest was successfully created." }
+ format.json { render :show, status: :created, location: @guest }
+ else
+ format.html { render :new, status: :unprocessable_entity }
+ format.json { render json: @guest.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # PATCH/PUT /guests/1 or /guests/1.json
+ def update
+ respond_to do |format|
+ if @guest.update(guest_params)
+ format.html { redirect_to guest_url(@guest), notice: "Guest was successfully updated." }
+ format.json { render :show, status: :ok, location: @guest }
+ else
+ format.html { render :edit, status: :unprocessable_entity }
+ format.json { render json: @guest.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /guests/1 or /guests/1.json
+ def destroy
+ @guest.destroy!
+
+ respond_to do |format|
+ format.html { redirect_to guests_url, notice: "Guest was successfully destroyed." }
+ format.json { head :no_content }
+ end
+ end
+
+ private
+ # Use callbacks to share common setup or constraints between actions.
+ def set_guest
+ @guest = Guest.find(params[:id])
+ end
+
+ # Only allow a list of trusted parameters through.
+ def guest_params
+ params.require(:guest).permit(:first_name, :last_name, :email, :phone)
+ end
+end
diff --git a/app/helpers/guests_helper.rb b/app/helpers/guests_helper.rb
new file mode 100644
index 0000000..00317bf
--- /dev/null
+++ b/app/helpers/guests_helper.rb
@@ -0,0 +1,2 @@
+module GuestsHelper
+end
diff --git a/app/models/guest.rb b/app/models/guest.rb
new file mode 100644
index 0000000..b7d4d96
--- /dev/null
+++ b/app/models/guest.rb
@@ -0,0 +1,2 @@
+class Guest < ApplicationRecord
+end
diff --git a/app/views/guests/_form.html.erb b/app/views/guests/_form.html.erb
new file mode 100644
index 0000000..eaea454
--- /dev/null
+++ b/app/views/guests/_form.html.erb
@@ -0,0 +1,37 @@
+<%= form_with(model: guest) do |form| %>
+ <% if guest.errors.any? %>
+
+
<%= pluralize(guest.errors.count, "error") %> prohibited this guest from being saved:
+
+
+ <% guest.errors.each do |error| %>
+ - <%= error.full_message %>
+ <% end %>
+
+
+ <% end %>
+
+
+ <%= form.label :first_name, style: "display: block" %>
+ <%= form.text_field :first_name %>
+
+
+
+ <%= form.label :last_name, style: "display: block" %>
+ <%= form.text_field :last_name %>
+
+
+
+ <%= form.label :email, style: "display: block" %>
+ <%= form.text_field :email %>
+
+
+
+ <%= form.label :phone, style: "display: block" %>
+ <%= form.text_field :phone %>
+
+
+
+ <%= form.submit %>
+
+<% end %>
diff --git a/app/views/guests/_guest.html.erb b/app/views/guests/_guest.html.erb
new file mode 100644
index 0000000..dfd51e9
--- /dev/null
+++ b/app/views/guests/_guest.html.erb
@@ -0,0 +1,22 @@
+
+
+ First name:
+ <%= guest.first_name %>
+
+
+
+ Last name:
+ <%= guest.last_name %>
+
+
+
+ Email:
+ <%= guest.email %>
+
+
+
+ Phone:
+ <%= guest.phone %>
+
+
+
diff --git a/app/views/guests/edit.html.erb b/app/views/guests/edit.html.erb
new file mode 100644
index 0000000..a024444
--- /dev/null
+++ b/app/views/guests/edit.html.erb
@@ -0,0 +1,10 @@
+Editing guest
+
+<%= render "form", guest: @guest %>
+
+
+
+
+ <%= link_to "Show this guest", @guest %> |
+ <%= link_to "Back to guests", guests_path %>
+
diff --git a/app/views/guests/index.html.erb b/app/views/guests/index.html.erb
new file mode 100644
index 0000000..055e937
--- /dev/null
+++ b/app/views/guests/index.html.erb
@@ -0,0 +1,14 @@
+<%= notice %>
+
+Guests
+
+
+ <% @guests.each do |guest| %>
+ <%= render guest %>
+
+ <%= link_to "Show this guest", guest %>
+
+ <% end %>
+
+
+<%= link_to "New guest", new_guest_path %>
diff --git a/app/views/guests/new.html.erb b/app/views/guests/new.html.erb
new file mode 100644
index 0000000..d05ae72
--- /dev/null
+++ b/app/views/guests/new.html.erb
@@ -0,0 +1,9 @@
+New guest
+
+<%= render "form", guest: @guest %>
+
+
+
+
+ <%= link_to "Back to guests", guests_path %>
+
diff --git a/app/views/guests/show.html.erb b/app/views/guests/show.html.erb
new file mode 100644
index 0000000..bcfad6e
--- /dev/null
+++ b/app/views/guests/show.html.erb
@@ -0,0 +1,10 @@
+<%= notice %>
+
+<%= render @guest %>
+
+
+ <%= link_to "Edit this guest", edit_guest_path(@guest) %> |
+ <%= link_to "Back to guests", guests_path %>
+
+ <%= button_to "Destroy this guest", @guest, method: :delete %>
+
diff --git a/config/routes.rb b/config/routes.rb
index 8a4ea4a..fb63987 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,4 +1,5 @@
Rails.application.routes.draw do
+ resources :guests
resources :expenses
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
diff --git a/db/migrate/20240711180753_create_guests.rb b/db/migrate/20240711180753_create_guests.rb
new file mode 100644
index 0000000..8e62076
--- /dev/null
+++ b/db/migrate/20240711180753_create_guests.rb
@@ -0,0 +1,12 @@
+class CreateGuests < ActiveRecord::Migration[7.1]
+ def change
+ create_table :guests do |t|
+ t.string :first_name
+ t.string :last_name
+ t.string :email
+ t.string :phone
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 7774eec..9eb19ab 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema[7.1].define(version: 2024_07_11_175425) do
+ActiveRecord::Schema[7.1].define(version: 2024_07_11_180753) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -26,4 +26,13 @@ ActiveRecord::Schema[7.1].define(version: 2024_07_11_175425) do
t.datetime "updated_at", null: false
end
+ create_table "guests", force: :cascade do |t|
+ t.string "first_name"
+ t.string "last_name"
+ t.string "email"
+ t.string "phone"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
+
end
diff --git a/spec/models/guest_spec.rb b/spec/models/guest_spec.rb
new file mode 100644
index 0000000..1e6abc7
--- /dev/null
+++ b/spec/models/guest_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe Guest, type: :model do
+ pending "add some examples to (or delete) #{__FILE__}"
+end