Render the application’s layout
This commit adds a SeatsController
class to serve requests made to
routes like:
/venues/benedum_center/floors/orchestra/seats
This commit relies upon Rails’ conventional controller action
rendering .
To declare a controller “action”, a controller that extends from
ActionController::Base
can either:
define an instance method that corresponds to the action (in this
case, an #index
instance method)
declare a view file named after the action in the directory that
corresponds to the controller name (in this case,
app/views/seats/index.html.erb
)
If a method that corresponds to the action does not exist, Rails will
automatically infer which template to render .
The controller has no methods defined, and declares a seats#index
view
template in the
app/views/seats/index.html.erb
file.
The seats#index
renders static HTML that relies upon the pre-defined
CSS styling rules.
This static HTML serves as the Seats page’s layout. We’ll make the
contents of the page dynamic in subsequent commits.
Desktop
Collapse app/controllers/seats_controller.rb
Expand app/controllers/seats_controller.rb
app/controllers/seats_controller.rb
diff --git a/app/controllers/seats_controller.rb b/app/controllers/seats_controller.rb
new file mode 100644
index 0000000..e277dbf
--- /dev/null
+++ b/app/controllers/seats_controller.rb
@@ -0,0 +1,2 @@
+class SeatsController < ApplicationController
+end
Collapse app/views/layouts/application.html.erb
Expand app/views/layouts/application.html.erb
app/views/layouts/application.html.erb
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index 6400ae6..833b309 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -2,6 +2,7 @@
<html>
<head>
<title>SelectYourOwnSeat</title>
+ <meta name="viewport" content="width=device-width, initial-scale=1">
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
@@ -10,6 +11,8 @@
</head>
<body>
- <%= yield %>
+ <div class="syos-site-frame">
+ <%= yield %>
+ </div>
</body>
</html>
Collapse app/views/seats/index.html.erb
Expand app/views/seats/index.html.erb
app/views/seats/index.html.erb
diff --git a/app/views/seats/index.html.erb b/app/views/seats/index.html.erb
new file mode 100644
index 0000000..fbe7def
--- /dev/null
+++ b/app/views/seats/index.html.erb
@@ -0,0 +1,57 @@
+<header class="syos-site-frame__header syos-site-header">
+ <p class="syos-site-header__subtext">
+ Venue Name
+ </p>
+</header>
+
+<main class="syos-site-frame__main">
+ <section
+ class="syos-frame"
+ >
+ <div class="syos-frame__map">
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ class="syos-seat-map"
+ width="1600px"
+ height="1600px"
+ viewBox="0 0 1600 1600"
+ >
+ <rect fill="none" x="0" y="0" width="1600" height="1600"></rect>
+ </svg>
+ </div>
+
+ <div class="syos-frame__sidebar">
+ <div id="cart-summary">
+ <h2 class="syos-u-margin-bottom-2">
+ Your seat selections
+ </h2>
+
+ <p class="syos-u-font-size-small syos-u-margin-bottom-2">
+ Seats are not reserved until added to the cart.
+ </p>
+
+ <table class="syos-table">
+ <thead>
+ <tr>
+ <th>
+ Seat
+ </th>
+
+ <th class="syos-table__cell--numerals">
+ Price
+ </th>
+
+ <th class="visually-hidden">
+ Remove
+ </th>
+ </tr>
+ </thead>
+
+ <tbody>
+ </tbody>
+ </table>
+ </div>
+ </div>
+ </section>
+</main>
Collapse config/routes.rb
Expand config/routes.rb
config/routes.rb
diff --git a/config/routes.rb b/config/routes.rb
index c06383a..2b9f710 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,3 +1,10 @@
Rails.application.routes.draw do
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
+ resources :venues, only: [] do
+ resources :floors, only: [] do
+ resources :seats, only: [:index]
+ end
+ end
+
+ root to: redirect("/venues/benedum_center/floors/orchestra/seats")
end