summaryrefslogtreecommitdiff
path: root/app/views
diff options
context:
space:
mode:
Diffstat (limited to 'app/views')
-rw-r--r--app/views/users/_form.html.erb25
-rw-r--r--app/views/users/edit.html.erb6
-rw-r--r--app/views/users/index.html.erb29
-rw-r--r--app/views/users/index.json.jbuilder4
-rw-r--r--app/views/users/show.html.erb3
-rw-r--r--app/views/users/show.json.jbuilder1
6 files changed, 68 insertions, 0 deletions
diff --git a/app/views/users/_form.html.erb b/app/views/users/_form.html.erb
new file mode 100644
index 0000000..56d9f90
--- /dev/null
+++ b/app/views/users/_form.html.erb
@@ -0,0 +1,25 @@
+<%= form_for(@user) do |f| %>
+ <% if @user.errors.any? %>
+ <div id="error_explanation">
+ <h2><%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:</h2>
+
+ <ul>
+ <% @user.errors.full_messages.each do |msg| %>
+ <li><%= msg %></li>
+ <% end %>
+ </ul>
+ </div>
+ <% end %>
+
+ <div class="field">
+ <%= f.label :name %><br>
+ <%= f.text_area :name %>
+ </div>
+ <div class="field">
+ <%= f.label :pw_hash %><br>
+ <%= f.text_area :pw_hash %>
+ </div>
+ <div class="actions">
+ <%= f.submit %>
+ </div>
+<% end %>
diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb
new file mode 100644
index 0000000..99bd4cc
--- /dev/null
+++ b/app/views/users/edit.html.erb
@@ -0,0 +1,6 @@
+<h1>Editing user</h1>
+
+<%= render 'form' %>
+
+<%= link_to 'Show', @user %> |
+<%= link_to 'Back', users_path %>
diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb
new file mode 100644
index 0000000..8b9056b
--- /dev/null
+++ b/app/views/users/index.html.erb
@@ -0,0 +1,29 @@
+<h1>Listing users</h1>
+
+<table>
+ <thead>
+ <tr>
+ <th>Name</th>
+ <th>Pw hash</th>
+ <th></th>
+ <th></th>
+ <th></th>
+ </tr>
+ </thead>
+
+ <tbody>
+ <% @users.each do |user| %>
+ <tr>
+ <td><%= user.name %></td>
+ <td><%= user.pw_hash %></td>
+ <td><%= link_to 'Show', user %></td>
+ <td><%= link_to 'Edit', edit_user_path(user) %></td>
+ <td><%= link_to 'Destroy', user, method: :delete, data: { confirm: 'Are you sure?' } %></td>
+ </tr>
+ <% end %>
+ </tbody>
+</table>
+
+<br>
+
+<%= link_to 'New User', new_user_path %>
diff --git a/app/views/users/index.json.jbuilder b/app/views/users/index.json.jbuilder
new file mode 100644
index 0000000..182437e
--- /dev/null
+++ b/app/views/users/index.json.jbuilder
@@ -0,0 +1,4 @@
+json.array!(@users) do |user|
+ json.extract! user, :id, :name, :pw_hash
+ json.url user_url(user, format: :json)
+end
diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb
new file mode 100644
index 0000000..43c12fe
--- /dev/null
+++ b/app/views/users/show.html.erb
@@ -0,0 +1,3 @@
+app/views/users/show.html.erb
+
+<%= @user.name %>, <%= @user.email %>
diff --git a/app/views/users/show.json.jbuilder b/app/views/users/show.json.jbuilder
new file mode 100644
index 0000000..1262e80
--- /dev/null
+++ b/app/views/users/show.json.jbuilder
@@ -0,0 +1 @@
+json.extract! @user, :id, :name, :pw_hash, :created_at, :updated_at