Improve the demo experience
This commit is contained in:
15
rails-app/app/views/layouts/application.html.erb
Normal file
15
rails-app/app/views/layouts/application.html.erb
Normal file
@ -0,0 +1,15 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>App</title>
|
||||
<%= csrf_meta_tags %>
|
||||
<%= csp_meta_tag %>
|
||||
|
||||
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
|
||||
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<%= yield %>
|
||||
</body>
|
||||
</html>
|
13
rails-app/app/views/layouts/mailer.html.erb
Normal file
13
rails-app/app/views/layouts/mailer.html.erb
Normal file
@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<style>
|
||||
/* Email styles need to be inline */
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<%= yield %>
|
||||
</body>
|
||||
</html>
|
1
rails-app/app/views/layouts/mailer.text.erb
Normal file
1
rails-app/app/views/layouts/mailer.text.erb
Normal file
@ -0,0 +1 @@
|
||||
<%= yield %>
|
32
rails-app/app/views/products/_form.html.erb
Normal file
32
rails-app/app/views/products/_form.html.erb
Normal file
@ -0,0 +1,32 @@
|
||||
<%= form_with(model: product, local: true) do |form| %>
|
||||
<% if product.errors.any? %>
|
||||
<div id="error_explanation">
|
||||
<h2><%= pluralize(product.errors.count, "error") %> prohibited this product from being saved:</h2>
|
||||
|
||||
<ul>
|
||||
<% product.errors.full_messages.each do |message| %>
|
||||
<li><%= message %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="field">
|
||||
<%= form.label :name %>
|
||||
<%= form.text_field :name %>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<%= form.label :description %>
|
||||
<%= form.text_area :description %>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<%= form.label :price %>
|
||||
<%= form.text_field :price %>
|
||||
</div>
|
||||
|
||||
<div class="actions">
|
||||
<%= form.submit %>
|
||||
</div>
|
||||
<% end %>
|
2
rails-app/app/views/products/_product.json.jbuilder
Normal file
2
rails-app/app/views/products/_product.json.jbuilder
Normal file
@ -0,0 +1,2 @@
|
||||
json.extract! product, :id, :name, :description, :price, :created_at, :updated_at
|
||||
json.url product_url(product, format: :json)
|
6
rails-app/app/views/products/edit.html.erb
Normal file
6
rails-app/app/views/products/edit.html.erb
Normal file
@ -0,0 +1,6 @@
|
||||
<h1>Editing Product</h1>
|
||||
|
||||
<%= render 'form', product: @product %>
|
||||
|
||||
<%= link_to 'Show', @product %> |
|
||||
<%= link_to 'Back', products_path %>
|
31
rails-app/app/views/products/index.html.erb
Normal file
31
rails-app/app/views/products/index.html.erb
Normal file
@ -0,0 +1,31 @@
|
||||
<p id="notice"><%= notice %></p>
|
||||
|
||||
<h1>Products</h1>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Description</th>
|
||||
<th>Price</th>
|
||||
<th colspan="3"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<% @products.each do |product| %>
|
||||
<tr>
|
||||
<td><%= product.name %></td>
|
||||
<td><%= product.description %></td>
|
||||
<td><%= product.price %></td>
|
||||
<td><%= link_to 'Show', product %></td>
|
||||
<td><%= link_to 'Edit', edit_product_path(product) %></td>
|
||||
<td><%= link_to 'Destroy', product, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<br>
|
||||
|
||||
<%= link_to 'New Product', new_product_path %>
|
1
rails-app/app/views/products/index.json.jbuilder
Normal file
1
rails-app/app/views/products/index.json.jbuilder
Normal file
@ -0,0 +1 @@
|
||||
json.array! @products, partial: 'products/product', as: :product
|
5
rails-app/app/views/products/new.html.erb
Normal file
5
rails-app/app/views/products/new.html.erb
Normal file
@ -0,0 +1,5 @@
|
||||
<h1>New Product</h1>
|
||||
|
||||
<%= render 'form', product: @product %>
|
||||
|
||||
<%= link_to 'Back', products_path %>
|
19
rails-app/app/views/products/show.html.erb
Normal file
19
rails-app/app/views/products/show.html.erb
Normal file
@ -0,0 +1,19 @@
|
||||
<p id="notice"><%= notice %></p>
|
||||
|
||||
<p>
|
||||
<strong>Name:</strong>
|
||||
<%= @product.name %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Description:</strong>
|
||||
<%= @product.description %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Price:</strong>
|
||||
<%= @product.price %>
|
||||
</p>
|
||||
|
||||
<%= link_to 'Edit', edit_product_path(@product) %> |
|
||||
<%= link_to 'Back', products_path %>
|
1
rails-app/app/views/products/show.json.jbuilder
Normal file
1
rails-app/app/views/products/show.json.jbuilder
Normal file
@ -0,0 +1 @@
|
||||
json.partial! "products/product", product: @product
|
Reference in New Issue
Block a user