diff options
Diffstat (limited to 'app/views/users')
-rw-r--r-- | app/views/users/_form.html.erb | 17 | ||||
-rw-r--r-- | app/views/users/edit.html.erb | 6 | ||||
-rw-r--r-- | app/views/users/index.html.erb | 25 | ||||
-rw-r--r-- | app/views/users/index.json.jbuilder | 4 | ||||
-rw-r--r-- | app/views/users/new.html.erb | 5 | ||||
-rw-r--r-- | app/views/users/show.html.erb | 4 | ||||
-rw-r--r-- | app/views/users/show.json.jbuilder | 1 |
7 files changed, 62 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..4835056 --- /dev/null +++ b/app/views/users/_form.html.erb @@ -0,0 +1,17 @@ +<%= 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="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..24a2548 --- /dev/null +++ b/app/views/users/index.html.erb @@ -0,0 +1,25 @@ +<h1>Listing users</h1> + +<table> + <thead> + <tr> + <th></th> + <th></th> + <th></th> + </tr> + </thead> + + <tbody> + <% @users.each do |user| %> + <tr> + <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..6684a9c --- /dev/null +++ b/app/views/users/index.json.jbuilder @@ -0,0 +1,4 @@ +json.array!(@users) do |user| + json.extract! user, :id + json.url user_url(user, format: :json) +end diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb new file mode 100644 index 0000000..efc0404 --- /dev/null +++ b/app/views/users/new.html.erb @@ -0,0 +1,5 @@ +<h1>New user</h1> + +<%= render 'form' %> + +<%= link_to 'Back', users_path %> diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb new file mode 100644 index 0000000..32abeb0 --- /dev/null +++ b/app/views/users/show.html.erb @@ -0,0 +1,4 @@ +<p id="notice"><%= notice %></p> + +<%= link_to 'Edit', edit_user_path(@user) %> | +<%= link_to 'Back', users_path %> diff --git a/app/views/users/show.json.jbuilder b/app/views/users/show.json.jbuilder new file mode 100644 index 0000000..80ed63e --- /dev/null +++ b/app/views/users/show.json.jbuilder @@ -0,0 +1 @@ +json.extract! @user, :id, :created_at, :updated_at |