Permalink
Browse files

User signup complete

  • Loading branch information...
1 parent f673504 commit 4eded694f5a353f5520df1f63151d2d9db9b7cb5 @malbin committed Dec 10, 2011
View
@@ -33,8 +33,8 @@ group :development, :test do
gem 'sqlite3-ruby', :require => 'sqlite3'
gem 'gravatar_image_tag', '1.0.0.pre2'
## comment for heroku then: bundle exec rake assets:precompile
- #gem 'rspec-rails', '2.0.1'
- #gem 'rspec', '2.0.1'
+ gem 'rspec-rails', '2.0.1'
+ gem 'rspec', '2.0.1'
## end
gem 'webrat', '0.7.1'
gem 'spork', '0.8.4'
View
@@ -40,6 +40,7 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.1.3)
+ diff-lcs (1.1.3)
erubis (2.7.0)
execjs (1.2.11)
multi_json (~> 1.0)
@@ -90,6 +91,18 @@ GEM
rake (0.8.7)
rdoc (3.11)
json (~> 1.4)
+ rspec (2.0.1)
+ rspec-core (~> 2.0.1)
+ rspec-expectations (~> 2.0.1)
+ rspec-mocks (~> 2.0.1)
+ rspec-core (2.0.1)
+ rspec-expectations (2.0.1)
+ diff-lcs (>= 1.1.2)
+ rspec-mocks (2.0.1)
+ rspec-core (~> 2.0.1)
+ rspec-expectations (~> 2.0.1)
+ rspec-rails (2.0.1)
+ rspec (~> 2.0.0)
sass (3.1.11)
sass-rails (3.1.5)
actionpack (~> 3.1.0)
@@ -132,6 +145,8 @@ DEPENDENCIES
pg
rails (= 3.1.3)
rake (= 0.8.7)
+ rspec (= 2.0.1)
+ rspec-rails (= 2.0.1)
sass-rails (~> 3.1.5)
spork (= 0.8.4)
sqlite3-ruby
@@ -1,134 +1,178 @@
.container {
- width: 710px;
+width: 710px;
}
body {
- background: #cff;
+background: #cff;
}
header {
- padding-top: 20px;
+padding-top: 20px;
}
header img {
- padding: 1em;
- background: #fff;
+padding: 1em;
+background: #fff;
}
section {
- margin-top: 1em;
- font-size: 120%;
- padding: 20px;
- background: #fff;
+margin-top: 1em;
+font-size: 120%;
+padding: 20px;
+background: #fff;
}
section h1 {
- font-size: 200%;
+font-size: 200%;
}
/* Links */
a {
- color: #09c;
- text-decoration: none;
+color: #09c;
+text-decoration: none;
}
a:hover {
- color: #069;
- text-decoration: underline;
+color: #069;
+text-decoration: underline;
}
a:visited {
- color: #069;
+color: #069;
}
/* Navigation */
nav {
- float: right;
+float: right;
}
nav {
- background-color: white;
- padding: 0 0.7em;
- white-space: nowrap;
+background-color: white;
+padding: 0 0.7em;
+white-space: nowrap;
}
nav ul {
- margin: 0;
- padding: 0;
+margin: 0;
+padding: 0;
}
nav ul li {
- list-style-type: none;
- display: inline-block;
- padding: 0.2em 0;
+list-style-type: none;
+display: inline-block;
+padding: 0.2em 0;
}
nav ul li a {
- padding: 0 5px;
- font-weight: bold;
+padding: 0 5px;
+font-weight: bold;
}
nav ul li a:visited {
- color:#09c;
+color:#09c;
}
nav ul li a:hover {
- text-decoration: underline;
+text-decoration: underline;
}
/* sign up button */
a.signup_button {
- margin-left: auto;
- margin-right: auto;
- display: block;
- text-align: center;
- width: 190px;
- color: #fff;
- background: #006400;
- font-size: 150%;
- font-weight: bold;
- padding: 20px;
+margin-left: auto;
+margin-right: auto;
+display: block;
+text-align: center;
+width: 190px;
+color: #fff;
+background: #006400;
+font-size: 150%;
+font-weight: bold;
+padding: 20px;
}
.round {
- -moz-border-radius: 10px;
- -webkit-border-radius: 10px;
- border-radius: 10px;
+-moz-border-radius: 10px;
+-webkit-border-radius: 10px;
+border-radius: 10px;
}
footer {
- text-align: center;
- margin-top: 10px;
- width: 710px;
- margin-left: auto;
- margin-right: auto;
+text-align: center;
+margin-top: 10px;
+width: 710px;
+margin-left: auto;
+margin-right: auto;
}
footer nav {
- float: none;
+float: none;
}
/* user show page */
table.profile {
- width: 100%;
- margin-bottom: 0;
+width: 100%;
+margin-bottom: 0;
}
td.main {
- width: 70%;
- padding: 1em;
+width: 70%;
+padding: 1em;
}
td.sidebar {
- width: 30%;
- padding: 1em;
- vertical-align: top;
- background: #ffc;
+width: 30%;
+padding: 1em;
+vertical-align: top;
+background: #ffc;
}
.profile img.gravatar {
- border: 1px solid #999;
- margin-bottom: -15px;
+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;
}
@@ -1,12 +1,23 @@
class UsersController < ApplicationController
-
+
def show
@user = User.find(params[:id])
@title = @user.name
- end
+ end
- def new
+ def new
+ @user = User.new
@title = "Sign up"
- end
+ end
+ def create
+ @user = User.new(params[:user])
+ if @user.save
+ flash[:success] = "Welcome to the Sample App!"
+ redirect_to @user
+ else
+ @title = "Sign up"
+ render 'new'
+ end
+ end
end
@@ -10,6 +10,9 @@
<div class="container">
<%= render 'layouts/header' %>
<section class="round">
+ <% flash.each do |key, value| %>
+ <div class="flash <%= key %>"><%= value %></div>
+ <% end %>
<%= yield %>
</section>
<%= render 'layouts/footer' %>
@@ -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 %>
@@ -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 %><br />
+ <%= f.password_field :password_confirmation %>
+ </div>
+ <div class="actions">
+ <%= f.submit "Sign up" %>
+ </div>
+<% end %>
Oops, something went wrong.

0 comments on commit 4eded69

Please sign in to comment.