Skip to content

Commit ddc07ea

Browse files
committed
adding user signup page
1 parent ce09b2c commit ddc07ea

File tree

12 files changed

+177
-6
lines changed

12 files changed

+177
-6
lines changed

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ gem 'bcrypt-ruby', '3.1.2'
99
gem 'faker', '1.1.2'
1010
gem 'will_paginate', '3.0.4'
1111
gem 'bootstrap-will_paginate', '0.0.9'
12+
gem "paperclip", "~> 4.2"
1213

1314
group :development, :test do
1415
gem 'sqlite3', '1.3.8'

Gemfile.lock

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ GEM
4040
xpath (~> 2.0)
4141
childprocess (0.5.3)
4242
ffi (~> 1.0, >= 1.0.11)
43+
climate_control (0.0.3)
44+
activesupport (>= 3.0)
45+
cocaine (0.5.4)
46+
climate_control (>= 0.0.3, < 1.0)
4347
coffee-rails (4.0.1)
4448
coffee-script (>= 2.2.0)
4549
railties (>= 4.0.0, < 5.0)
@@ -75,6 +79,11 @@ GEM
7579
multi_json (1.10.1)
7680
nokogiri (1.6.3.1)
7781
mini_portile (= 0.6.0)
82+
paperclip (4.2.0)
83+
activemodel (>= 3.0.0)
84+
activesupport (>= 3.0.0)
85+
cocaine (~> 0.5.3)
86+
mime-types
7887
pg (0.15.1)
7988
polyglot (0.3.5)
8089
rack (1.5.2)
@@ -167,6 +176,7 @@ DEPENDENCIES
167176
faker (= 1.1.2)
168177
jbuilder (= 1.0.2)
169178
jquery-rails (= 3.0.4)
179+
paperclip (~> 4.2)
170180
pg (= 0.15.1)
171181
rails (= 4.0.8)
172182
rails_12factor (= 0.0.2)

app/assets/stylesheets/custom.css.scss

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
@import "bootstrap";
22

3+
$grayMediumLight: #eaeaea;
4+
5+
@mixin box_sizing {
6+
-moz-box-sizing: border-box;
7+
-webkit-box-sizing: border-box;
8+
box-sizing: border-box;
9+
}
10+
311
/* universal */
412

513
html {
@@ -50,4 +58,40 @@ footer {
5058
margin-left: 10px;
5159
}
5260
}
61+
}
62+
63+
/* miscellaneous */
64+
65+
.debug_dump {
66+
clear: both;
67+
float: left;
68+
width: 100%;
69+
margin-top: 45px;
70+
@include box_sizing;
71+
}
72+
73+
/* forms */
74+
75+
input, textarea, select, .uneditable-input {
76+
border: 1px solid #bbb;
77+
width: 100%;
78+
margin-bottom: 15px;
79+
@include box_sizing;
80+
}
81+
82+
input {
83+
height: auto !important;
84+
}
85+
86+
#error_explanation {
87+
color: #f00;
88+
ul {
89+
list-style: none;
90+
margin: 0 0 18px 0;
91+
}
92+
}
93+
94+
.field_with_errors {
95+
@extend .control-group;
96+
@extend .error;
5397
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,24 @@
11
class UsersController < ApplicationController
22
def new
3+
@user = User.new
34
end
5+
6+
def show
7+
@user = User.find(params[:id])
8+
end
9+
10+
def create
11+
@user = User.new(user_params)
12+
if @user.save
13+
flash[:success] = "Welcome to the Cooperative Gallery"
14+
redirect_to @user
15+
else
16+
render 'new'
17+
end
18+
end
19+
20+
private
21+
def user_params
22+
params.require(:user).permit(:name, :email, :biography, :password, :password_confirmation)
23+
end
424
end
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<% if @user.errors.any? %>
2+
<div id="error_explanation">
3+
<div class="alert alert-error">
4+
The form contains <%= pluralize(@user.errors.count, "error") %>.
5+
</div>
6+
<ul>
7+
<% @user.errors.full_messages.each do |msg| %>
8+
<li>* <%= msg %></li>
9+
<% end %>
10+
</ul>
11+
</div>
12+
<% end %>

app/views/users/new.html.erb

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,26 @@
1-
<h1>Users#new</h1>
2-
<p>Find me in app/views/users/new.html.erb</p>
1+
<% provide(:title, 'Sign up') %>
2+
<h1>Sign up</h1>
3+
4+
<div class='row'>
5+
<div class='span6 offset3'>
6+
<%= form_for(@user) do |f| %>
7+
<%= render 'shared/error_messages' %>
8+
<%= f.label :name %>
9+
<%= f.text_field :name %>
10+
11+
<%= f.label :email %>
12+
<%= f.text_field :email %>
13+
14+
<%= f.label :biography %>
15+
<%= f.text_area :biography, :cols => "10", :rows => "10" %>
16+
17+
<%= f.label :password %>
18+
<%= f.password_field :password %>
19+
20+
<%= f.label :password_confirmation, "Confirmation" %>
21+
<%= f.password_field :password_confirmation %>
22+
23+
<%= f.submit "Create my account", class: "btn btn-large btn-primary" %>
24+
<% end %>
25+
</div>
26+
</div>

app/views/users/show.html.erb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<% provide(:title, @user.name) %>
2+
<h1><%= @user.name %></h1>

config/environments/production.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
4141

4242
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
43-
# config.force_ssl = true
43+
config.force_ssl = true
4444

4545
# Set to :debug to see everything in the log.
4646
config.log_level = :info

config/environments/test.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,7 @@
3636

3737
# Raises error for missing translations
3838
# config.action_view.raise_on_missing_translations = true
39+
40+
# Speed up tests by lowering bcrypt's cost function.
41+
ActiveModel::SecurePassword.min_cost = true
3942
end

config/routes.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
Rails.application.routes.draw do
22
resources :shows
33
resources :links, only: [:index]
4+
resources :users
45
root 'shows#current'
6+
match '/signup', to: 'users#new', via: 'get'
7+
match '/signin', to: 'sessions#new', via: 'get'
8+
match '/signout', to: 'sessions#destroy', via: 'delete'
9+
match '/signup', to: 'users#new', via: 'get'
510
match '/about', to: 'static_pages#about', via: 'get'
611
match '/contact', to: 'static_pages#contact', via: 'get'
712
# The priority is based upon order of creation: first created -> highest priority.

0 commit comments

Comments
 (0)