summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2014-03-04 17:09:00 -0500
committerLuke Shumaker <LukeShu@sbcglobal.net>2014-03-04 17:09:00 -0500
commitf10de077a7d5d6978bcb6d1264aa14880d4ce6b0 (patch)
tree812f051acdda69aea3ff8ef006f28d96f0e4a0c7
parent89cf8c1bf9b528b739794071cc035121fa962c1a (diff)
show errors when signing up
-rw-r--r--app/views/common/_error_messages.html.erb11
-rw-r--r--app/views/users/new.html.erb36
2 files changed, 15 insertions, 32 deletions
diff --git a/app/views/common/_error_messages.html.erb b/app/views/common/_error_messages.html.erb
new file mode 100644
index 0000000..c9fdd51
--- /dev/null
+++ b/app/views/common/_error_messages.html.erb
@@ -0,0 +1,11 @@
+<%# http://railscasts.com/episodes/211-validations-in-rails-3 %>
+<% if target.errors.any? %>
+<div id="errorExplanation">
+ <h2><%= pluralize(target.errors.count, "error") %> prohibited this record from being saved:</h2>
+ <ul>
+ <% target.errors.full_messages.each do |msg| %>
+ <li><%= msg %></li>
+ <% end %>
+ </ul>
+</div>
+<% end %>
diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb
index f0ce746..704aa10 100644
--- a/app/views/users/new.html.erb
+++ b/app/views/users/new.html.erb
@@ -1,12 +1,12 @@
<h1> Sign Up </h1>
-<% if false %>
-<%= form_for :user do |f| %>
+<%= form_for @user do |f| %>
+ <%= render "common/error_messages", :target => @user %>
<p>
<%= f.label :name %><br>
<%= f.text_field :name %>
</p>
- <p>
+ <p>
<%= f.label :email %><br>
<%= f.text_field :email %>
</p>
@@ -14,7 +14,7 @@
<%= f.label :user_name %><br>
<%= f.text_field :user_name %>
</p>
- <p>
+ <p>
<%= f.label :password %><br>
<%= f.password_field :password %>
</p>
@@ -28,33 +28,5 @@
<% end %>
-<% end %>
-
-<form accept-charset="UTF-8" action="/users" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="&#x2713;" /><input name="authenticity_token" type="hidden" value="6WQoPLFISlDYCsi4LhAgT0hgrht19yydD3w5TlKfb7I=" /></div>
- <p>
- <label for="user_name">Name</label><br>
- <input id="user_name" name="user[name]" type="text" />
- </p>
- <p>
- <label for="user_email">Email</label><br>
- <input id="user_email" name="user[email]" type="text" />
- </p>
- <p>
- <label for="user_user_name">User name</label><br>
- <input id="user_user_name" name="user[user_name]" type="text" />
- </p>
- <p>
- <label for="user_password">Password</label><br>
- <input id="user_password" name="user[password]" type="password" />
- </p>
- <p>
- <label for="user_password_confirm">Password confirm</label><br>
- <input id="user_password_confirmation" name="user[password_confirmation]" type="password" />
- </p>
- <p>
- <input name="commit" type="submit" value="Save User" />
- </p>
-</form>
-
<%= link_to 'Already Have an Account? Log in', new_session_path, :class => "btn btn-warning btn-lg" %>