From f10de077a7d5d6978bcb6d1264aa14880d4ce6b0 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Tue, 4 Mar 2014 17:09:00 -0500 Subject: show errors when signing up --- app/views/common/_error_messages.html.erb | 11 ++++++++++ app/views/users/new.html.erb | 36 ++++--------------------------- 2 files changed, 15 insertions(+), 32 deletions(-) create mode 100644 app/views/common/_error_messages.html.erb (limited to 'app') 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? %> +
+

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

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

Sign Up

-<% if false %> -<%= form_for :user do |f| %> +<%= form_for @user do |f| %> + <%= render "common/error_messages", :target => @user %>

<%= f.label :name %>
<%= f.text_field :name %>

-

+

<%= f.label :email %>
<%= f.text_field :email %>

@@ -14,7 +14,7 @@ <%= f.label :user_name %>
<%= f.text_field :user_name %>

-

+

<%= f.label :password %>
<%= f.password_field :password %>

@@ -28,33 +28,5 @@ <% end %> -<% end %> - -
-

-
- -

-

-
- -

-

-
- -

-

-
- -

-

-
- -

-

- -

-
- <%= link_to 'Already Have an Account? Log in', new_session_path, :class => "btn btn-warning btn-lg" %> -- cgit v1.2.3-54-g00ecf