-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modeling users #55
Modeling users #55
Conversation
app/assets/javascripts/users.coffee
Outdated
@@ -0,0 +1,3 @@ | |||
# Place all the behaviors and hooks related to the matching controller here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
xóa file này
app/assets/stylesheets/users.scss
Outdated
@@ -0,0 +1,3 @@ | |||
// Place all the styles related to the Users controller here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
xóa file này
app/helpers/users_helper.rb
Outdated
@@ -0,0 +1,2 @@ | |||
module UsersHelper |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
xóa file này
app/models/user.rb
Outdated
@@ -0,0 +1,10 @@ | |||
class User < ApplicationRecord | |||
before_save {self.email = email.downcase} | |||
validates :name, presence: true, length: {maximum: 50} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cách bên trên 1 dòng trắng
app/models/user.rb
Outdated
before_save {self.email = email.downcase} | ||
validates :name, presence: true, length: {maximum: 50} | ||
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-]+(\.[a-z\d\-]+)*\.[a-z]+\z/i | ||
validates :email, presence: true, length: {maximum: 255}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+ validates :email, presence: true, length: {maximum: 255},
+ format: {with: VALID_EMAIL_REGEX},
+ uniqueness: {case_sensitive: false}
+ validates :password, presence: true, length: {minimum: 6}
+ has_secure_password
config/routes.rb
Outdated
@@ -1,6 +1,9 @@ | |||
Rails.application.routes.draw do | |||
get 'users/new' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dùng nháy kép đi nào :D
No description provided.