From a034c6fff6aad728eae7d7056e8e538f58a0e0e7 Mon Sep 17 00:00:00 2001 From: DavisLWebb Date: Mon, 3 Mar 2014 14:16:43 -0500 Subject: view stuff --- app/views/users/_form.html.erb | 25 +++++++++++++++++++++++++ app/views/users/edit.html.erb | 6 ++++++ app/views/users/index.html.erb | 29 +++++++++++++++++++++++++++++ app/views/users/index.json.jbuilder | 4 ++++ app/views/users/show.html.erb | 3 +++ app/views/users/show.json.jbuilder | 1 + 6 files changed, 68 insertions(+) create mode 100644 app/views/users/_form.html.erb create mode 100644 app/views/users/edit.html.erb create mode 100644 app/views/users/index.html.erb create mode 100644 app/views/users/index.json.jbuilder create mode 100644 app/views/users/show.html.erb create mode 100644 app/views/users/show.json.jbuilder (limited to 'app/views/users') 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? %> +
+

<%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:

+ + +
+ <% end %> + +
+ <%= f.label :name %>
+ <%= f.text_area :name %> +
+
+ <%= f.label :pw_hash %>
+ <%= f.text_area :pw_hash %> +
+
+ <%= f.submit %> +
+<% 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 @@ +

Editing user

+ +<%= 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 @@ +

Listing users

+ + + + + + + + + + + + + + <% @users.each do |user| %> + + + + + + + + <% end %> + +
NamePw hash
<%= user.name %><%= user.pw_hash %><%= link_to 'Show', user %><%= link_to 'Edit', edit_user_path(user) %><%= link_to 'Destroy', user, method: :delete, data: { confirm: 'Are you sure?' } %>
+ +
+ +<%= 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 -- cgit v1.2.3-54-g00ecf