Skip to content
Browse files

Done with user signup

  • Loading branch information...
1 parent c50b5a3 commit 39023232511d98df9ccf279f314b1ec4610b66e5 @rubydubee committed
View
BIN app/controllers/.users_controller.rb.swp
Binary file not shown.
View
12 app/controllers/users_controller.rb
@@ -1,5 +1,6 @@
class UsersController < ApplicationController
def new
+ @user = User.new
@title = "Sign up"
end
@@ -7,4 +8,15 @@ def show
@user = User.find(params[:id])
@title = @user.name
end
+
+ def create
+ @user = User.new(params[:user])
+ if @user.save
+ flash[:success] = "Welcome to Twittered!"
+ redirect_to @user
+ else
+ @title = "Sign up"
+ render "new"
+ end
+ end
end
View
BIN app/views/layouts/.application.html.erb.swp
Binary file not shown.
View
7 app/views/layouts/application.html.erb
@@ -9,10 +9,13 @@
<div class="container">
<%= render 'layouts/header' %>
<section class="round">
+ <% flash.each do |key, value| %>
+ <div class="flash <%= key %>"><%= value %></div>
+ <% end %>
<%= yield %>
- </section>
+ </section>
<%= render 'layouts/footer' %>
- <% debug(params) if Rails.env.development? %>
+ <%= debug(params) if Rails.env.development? %>
</div>
</body>
</html>
View
12 app/views/shared/_error_messages.html.erb
@@ -0,0 +1,12 @@
+<% if @user.errors.any? %>
+ <div id="error_explanation">
+ <h2><%= pluralize(@user.errors.count, "error") %>
+ prohibited this user from being saved:</h2>
+ <p>There were problems with the following fields:</p>
+ <ul>
+ <% @user.errors.full_messages.each do |msg| %>
+ <li><%= msg %></li>
+ <% end %>
+ </ul>
+ </div>
+<% end %>
View
26 app/views/users/new.html.erb
@@ -1,2 +1,24 @@
-<h1>Users#new</h1>
-<p>Find me in app/views/users/new.html.erb</p>
+<h1>Sign up</h1>
+
+<%= form_for(@user) do |f| %>
+<%= render 'shared/error_messages' %>
+ <div class="field">
+ <%= f.label :name %><br />
+ <%= f.text_field :name %>
+ </div>
+ <div class="field">
+ <%= f.label :email %><br />
+ <%= f.text_field :email %>
+ </div>
+ <div class="field">
+ <%= f.label :password %><br />
+ <%= f.password_field :password %>
+ </div>
+ <div class="field">
+ <%= f.label :password_confirmation, "Confirmation" %><br />
+ <%= f.password_field :password_confirmation %>
+ </div>
+ <div class="actions">
+ <%= f.submit "Sign up" %>
+ </div>
+<% end %>
View
45 public/stylesheets/custom.css
@@ -136,3 +136,48 @@ td.sidebar {
border: 1px solid #999;
margin-bottom: -15px;
}
+
+div.field, div.actions {
+ margin-bottom: 10px;
+}
+
+.field_with_errors {
+ margin-top: 10px;
+ padding: 2px;
+ background-color: red;
+ display: table;
+}
+
+.field_with_errors label {
+ color: #fff;
+}
+
+#error_explanation {
+ width: 400px;
+ border: 2px solid red;
+ padding: 7px;
+ padding-bottom: 12px;
+ margin-bottom: 20px;
+ background-color: #f0f0f0;
+}
+
+#error_explanation h2 {
+ text-align: left;
+ font-weight: bold;
+ padding: 5px 5px 5px 15px;
+ font-size: 12px;
+ margin: -7px;
+ background-color: #c00;
+ color: #fff;
+}
+
+#error_explanation p {
+ color: #333;
+ margin-bottom: 0;
+ padding: 5px;
+}
+
+#error_explanation ul li {
+ font-size: 12px;
+ list-style: square;
+}

0 comments on commit 3902323

Please sign in to comment.
Something went wrong with that request. Please try again.