Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
83 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
class UsersController < ApplicationController | ||
def new | ||
@user = User.new | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
class User < ActiveRecord::Base | ||
attr_accessible :email, :name | ||
attr_accessible :name, :email, :password, :password_confirmation | ||
has_secure_password | ||
|
||
before_save { |user| user.email = email.downcase } | ||
|
||
validates :name, presence: true, length: { maximum: 50 } | ||
validates :name, presence: true, length: { maximum: 50 } | ||
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i | ||
validates :email, presence: true, format: { with: VALID_EMAIL_REGEX }, | ||
validates :email, presence: true, | ||
format: { with: VALID_EMAIL_REGEX }, | ||
uniqueness: { case_sensitive: false } | ||
end | ||
validates :password, length: { minimum: 6 } | ||
validates :password_confirmation, presence: true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,19 @@ | ||
<h1>Users#new</h1> | ||
<p>Find me in app/views/users/new.html.erb</p> | ||
<h1>Sign Up</h1> | ||
|
||
<%= form_for(@user) do |f| %> | ||
<%= f.label :name %> | ||
<%= f.text_field :name %> | ||
<%= f.label :email %> | ||
<%= f.text_field :email %> | ||
<%= f.label :password %> | ||
<%= f.password_field :password %> | ||
<%= f.label :password_confirmation, "Confirmation" %> | ||
<%= f.password_field :password_confirmation %> | ||
<%= f.submit "Create my account" %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddPasswordDigestToUsers < ActiveRecord::Migration | ||
def change | ||
add_column :users, :password_digest, :string | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters