{"action":"created","comment":{"url":"https://api.github.com/repos/framgia/fels_65/pulls/comments/33430975","id":33430975,"diff_hunk":"@@ -9,4 +10,90 @@ class User < ActiveRecord::Base\n                                  dependent: :destroy\n   has_many :following, through: :active_relationships,  source: :followed\n   has_many :followers, through: :passive_relationships, source: :follower\n+  mount_uploader :avatar, AvatarUploader\n+  EMAIL_FORMAT = /\\A[\\w+\\-.]+@[a-z\\d\\-.]+\\.[a-z]+\\z/i\n+  has_secure_password\n+  validates :name, presence: true, length: {minimum: 2, maximum: 30}\n+  validates :email, presence: true, length: {maximum: 50}, format: {with: EMAIL_FORMAT},\n+                                uniqueness: true\n+  validates :password, presence: true, length: {minimum: 6, maximum: 255}, allow_nil: true\n+  validates :avatar, presence: true, allow_nil: true\n+  validate :avatar_size\n+  before_save :downcase_email\n+  before_create :create_activation_digest\n+\n+  def User.digest string\n+    cost = ActiveModel::SecurePassword.min_cost ? BCrypt::Engine::MIN_COST : BCrypt::Engine.cost\n+    BCrypt::Password.create(string, cost: cost)\n+  end\n+\n+  def User.new_token\n+    SecureRandom.urlsafe_base64\n+  end\n+\n+  def authenticated?(attribute, token)\n+    digest = send(\"#{attribute}_digest\")\n+    return false if digest.nil?\n+    BCrypt::Password.new(digest).is_password?(token)\n+  end\n+\n+  def remember\n+      self.remember_token = User.new_token\n+      update_attribute(:remember_digest, User.digest(remember_token))\n+  end\n+\n+  def forget\n+    update_attribute(:remember_token, nil)\n+  end\n+\n+  def follow other_user\n+    active_relationships.create(followed_id: other_user.id)\n+  end\n+\n+  def unfollow other_user\n+    active_relationships.find_by(followed_id: other_user.id).destroy\n+  end\n+\n+  def following?(other_user)\n+    following.include?(other_user)\n+  end\n+\n+  def activate\n+    update_attribute(:activated, true)\n+    update_attribute(:activated_at, Time.zone.now)\n+  end\n+\n+  def send_activation_email\n+    UserMailer.account_activation(self).deliver_now\n+  end\n+\n+  def password_reset_expired?\n+    reset_at < 2.hours.ago\n+  end\n+\n+  def send_password_reset_email\n+    UserMailer.password_reset(self).deliver_now\n+  end\n+\n+  def create_reset_digest\n+    self.reset_token = User.new_token\n+    update_attribute(:reset_digest, User.digest(reset_token))\n+    update_attribute(:reset_at, Time.zone.now)\n+  end\n+\n+  private\n+  def downcase_email\n+    self.email = email.downcase\n+  end\n+\n+  def avatar_size\n+    if avatar.size > 2.megabytes\n+      errors.add(:avatar, I18n.t(\"should_be_less_than\") + \"2 MB\")","path":"app/models/user.rb","position":88,"original_position":88,"commit_id":"2abfed1434ca8da1121abf50dac49602f4c4482b","original_commit_id":"2abfed1434ca8da1121abf50dac49602f4c4482b","user":{"login":"phamkykhoi","id":8532305,"avatar_url":"https://avatars.githubusercontent.com/u/8532305?v=3","gravatar_id":"","url":"https://api.github.com/users/phamkykhoi","html_url":"https://github.com/phamkykhoi","followers_url":"https://api.github.com/users/phamkykhoi/followers","following_url":"https://api.github.com/users/phamkykhoi/following{/other_user}","gists_url":"https://api.github.com/users/phamkykhoi/gists{/gist_id}","starred_url":"https://api.github.com/users/phamkykhoi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phamkykhoi/subscriptions","organizations_url":"https://api.github.com/users/phamkykhoi/orgs","repos_url":"https://api.github.com/users/phamkykhoi/repos","events_url":"https://api.github.com/users/phamkykhoi/events{/privacy}","received_events_url":"https://api.github.com/users/phamkykhoi/received_events","type":"User","site_admin":false},"body":" \"2 MB\" use I18n","created_at":"2015-06-29T02:25:36Z","updated_at":"2015-06-29T02:25:36Z","html_url":"https://github.com/framgia/fels_65/pull/4#discussion_r33430975","pull_request_url":"https://api.github.com/repos/framgia/fels_65/pulls/4","_links":{"self":{"href":"https://api.github.com/repos/framgia/fels_65/pulls/comments/33430975"},"html":{"href":"https://github.com/framgia/fels_65/pull/4#discussion_r33430975"},"pull_request":{"href":"https://api.github.com/repos/framgia/fels_65/pulls/4"}}},"pull_request":{"url":"https://api.github.com/repos/framgia/fels_65/pulls/4","id":38635935,"html_url":"https://github.com/framgia/fels_65/pull/4","diff_url":"https://github.com/framgia/fels_65/pull/4.diff","patch_url":"https://github.com/framgia/fels_65/pull/4.patch","issue_url":"https://api.github.com/repos/framgia/fels_65/issues/4","number":4,"state":"open","locked":false,"title":"SignUp, Account activation, Password reset, Update account","user":{"login":"nhs3108","id":10093701,"avatar_url":"https://avatars.githubusercontent.com/u/10093701?v=3","gravatar_id":"","url":"https://api.github.com/users/nhs3108","html_url":"https://github.com/nhs3108","followers_url":"https://api.github.com/users/nhs3108/followers","following_url":"https://api.github.com/users/nhs3108/following{/other_user}","gists_url":"https://api.github.com/users/nhs3108/gists{/gist_id}","starred_url":"https://api.github.com/users/nhs3108/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nhs3108/subscriptions","organizations_url":"https://api.github.com/users/nhs3108/orgs","repos_url":"https://api.github.com/users/nhs3108/repos","events_url":"https://api.github.com/users/nhs3108/events{/privacy}","received_events_url":"https://api.github.com/users/nhs3108/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-06-26T10:23:05Z","updated_at":"2015-06-29T02:25:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8e599f29eee1282bdb3100f6fdf6fdf2ca630da3","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/framgia/fels_65/pulls/4/commits","review_comments_url":"https://api.github.com/repos/framgia/fels_65/pulls/4/comments","review_comment_url":"https://api.github.com/repos/framgia/fels_65/pulls/comments{/number}","comments_url":"https://api.github.com/repos/framgia/fels_65/issues/4/comments","statuses_url":"https://api.github.com/repos/framgia/fels_65/statuses/2abfed1434ca8da1121abf50dac49602f4c4482b","head":{"label":"nhs3108:signup_activation_reset_update","ref":"signup_activation_reset_update","sha":"2abfed1434ca8da1121abf50dac49602f4c4482b","user":{"login":"nhs3108","id":10093701,"avatar_url":"https://avatars.githubusercontent.com/u/10093701?v=3","gravatar_id":"","url":"https://api.github.com/users/nhs3108","html_url":"https://github.com/nhs3108","followers_url":"https://api.github.com/users/nhs3108/followers","following_url":"https://api.github.com/users/nhs3108/following{/other_user}","gists_url":"https://api.github.com/users/nhs3108/gists{/gist_id}","starred_url":"https://api.github.com/users/nhs3108/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nhs3108/subscriptions","organizations_url":"https://api.github.com/users/nhs3108/orgs","repos_url":"https://api.github.com/users/nhs3108/repos","events_url":"https://api.github.com/users/nhs3108/events{/privacy}","received_events_url":"https://api.github.com/users/nhs3108/received_events","type":"User","site_admin":false},"repo":{"id":38027765,"name":"fels_65","full_name":"nhs3108/fels_65","owner":{"login":"nhs3108","id":10093701,"avatar_url":"https://avatars.githubusercontent.com/u/10093701?v=3","gravatar_id":"","url":"https://api.github.com/users/nhs3108","html_url":"https://github.com/nhs3108","followers_url":"https://api.github.com/users/nhs3108/followers","following_url":"https://api.github.com/users/nhs3108/following{/other_user}","gists_url":"https://api.github.com/users/nhs3108/gists{/gist_id}","starred_url":"https://api.github.com/users/nhs3108/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nhs3108/subscriptions","organizations_url":"https://api.github.com/users/nhs3108/orgs","repos_url":"https://api.github.com/users/nhs3108/repos","events_url":"https://api.github.com/users/nhs3108/events{/privacy}","received_events_url":"https://api.github.com/users/nhs3108/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nhs3108/fels_65","description":"Framgia E-Learning System (training)","fork":true,"url":"https://api.github.com/repos/nhs3108/fels_65","forks_url":"https://api.github.com/repos/nhs3108/fels_65/forks","keys_url":"https://api.github.com/repos/nhs3108/fels_65/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nhs3108/fels_65/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nhs3108/fels_65/teams","hooks_url":"https://api.github.com/repos/nhs3108/fels_65/hooks","issue_events_url":"https://api.github.com/repos/nhs3108/fels_65/issues/events{/number}","events_url":"https://api.github.com/repos/nhs3108/fels_65/events","assignees_url":"https://api.github.com/repos/nhs3108/fels_65/assignees{/user}","branches_url":"https://api.github.com/repos/nhs3108/fels_65/branches{/branch}","tags_url":"https://api.github.com/repos/nhs3108/fels_65/tags","blobs_url":"https://api.github.com/repos/nhs3108/fels_65/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nhs3108/fels_65/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nhs3108/fels_65/git/refs{/sha}","trees_url":"https://api.github.com/repos/nhs3108/fels_65/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nhs3108/fels_65/statuses/{sha}","languages_url":"https://api.github.com/repos/nhs3108/fels_65/languages","stargazers_url":"https://api.github.com/repos/nhs3108/fels_65/stargazers","contributors_url":"https://api.github.com/repos/nhs3108/fels_65/contributors","subscribers_url":"https://api.github.com/repos/nhs3108/fels_65/subscribers","subscription_url":"https://api.github.com/repos/nhs3108/fels_65/subscription","commits_url":"https://api.github.com/repos/nhs3108/fels_65/commits{/sha}","git_commits_url":"https://api.github.com/repos/nhs3108/fels_65/git/commits{/sha}","comments_url":"https://api.github.com/repos/nhs3108/fels_65/comments{/number}","issue_comment_url":"https://api.github.com/repos/nhs3108/fels_65/issues/comments{/number}","contents_url":"https://api.github.com/repos/nhs3108/fels_65/contents/{+path}","compare_url":"https://api.github.com/repos/nhs3108/fels_65/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nhs3108/fels_65/merges","archive_url":"https://api.github.com/repos/nhs3108/fels_65/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nhs3108/fels_65/downloads","issues_url":"https://api.github.com/repos/nhs3108/fels_65/issues{/number}","pulls_url":"https://api.github.com/repos/nhs3108/fels_65/pulls{/number}","milestones_url":"https://api.github.com/repos/nhs3108/fels_65/milestones{/number}","notifications_url":"https://api.github.com/repos/nhs3108/fels_65/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nhs3108/fels_65/labels{/name}","releases_url":"https://api.github.com/repos/nhs3108/fels_65/releases{/id}","created_at":"2015-06-25T04:27:11Z","updated_at":"2015-06-25T02:12:17Z","pushed_at":"2015-06-29T02:08:16Z","git_url":"git://github.com/nhs3108/fels_65.git","ssh_url":"git@github.com:nhs3108/fels_65.git","clone_url":"https://github.com/nhs3108/fels_65.git","svn_url":"https://github.com/nhs3108/fels_65","homepage":null,"size":0,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"framgia:develop","ref":"develop","sha":"2ed19c8028fc10cef3fda2c4af0616f368923dad","user":{"login":"framgia","id":2322183,"avatar_url":"https://avatars.githubusercontent.com/u/2322183?v=3","gravatar_id":"","url":"https://api.github.com/users/framgia","html_url":"https://github.com/framgia","followers_url":"https://api.github.com/users/framgia/followers","following_url":"https://api.github.com/users/framgia/following{/other_user}","gists_url":"https://api.github.com/users/framgia/gists{/gist_id}","starred_url":"https://api.github.com/users/framgia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/framgia/subscriptions","organizations_url":"https://api.github.com/users/framgia/orgs","repos_url":"https://api.github.com/users/framgia/repos","events_url":"https://api.github.com/users/framgia/events{/privacy}","received_events_url":"https://api.github.com/users/framgia/received_events","type":"Organization","site_admin":false},"repo":{"id":38022545,"name":"fels_65","full_name":"framgia/fels_65","owner":{"login":"framgia","id":2322183,"avatar_url":"https://avatars.githubusercontent.com/u/2322183?v=3","gravatar_id":"","url":"https://api.github.com/users/framgia","html_url":"https://github.com/framgia","followers_url":"https://api.github.com/users/framgia/followers","following_url":"https://api.github.com/users/framgia/following{/other_user}","gists_url":"https://api.github.com/users/framgia/gists{/gist_id}","starred_url":"https://api.github.com/users/framgia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/framgia/subscriptions","organizations_url":"https://api.github.com/users/framgia/orgs","repos_url":"https://api.github.com/users/framgia/repos","events_url":"https://api.github.com/users/framgia/events{/privacy}","received_events_url":"https://api.github.com/users/framgia/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/framgia/fels_65","description":"Framgia E-Learning System (training)","fork":false,"url":"https://api.github.com/repos/framgia/fels_65","forks_url":"https://api.github.com/repos/framgia/fels_65/forks","keys_url":"https://api.github.com/repos/framgia/fels_65/keys{/key_id}","collaborators_url":"https://api.github.com/repos/framgia/fels_65/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/framgia/fels_65/teams","hooks_url":"https://api.github.com/repos/framgia/fels_65/hooks","issue_events_url":"https://api.github.com/repos/framgia/fels_65/issues/events{/number}","events_url":"https://api.github.com/repos/framgia/fels_65/events","assignees_url":"https://api.github.com/repos/framgia/fels_65/assignees{/user}","branches_url":"https://api.github.com/repos/framgia/fels_65/branches{/branch}","tags_url":"https://api.github.com/repos/framgia/fels_65/tags","blobs_url":"https://api.github.com/repos/framgia/fels_65/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/framgia/fels_65/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/framgia/fels_65/git/refs{/sha}","trees_url":"https://api.github.com/repos/framgia/fels_65/git/trees{/sha}","statuses_url":"https://api.github.com/repos/framgia/fels_65/statuses/{sha}","languages_url":"https://api.github.com/repos/framgia/fels_65/languages","stargazers_url":"https://api.github.com/repos/framgia/fels_65/stargazers","contributors_url":"https://api.github.com/repos/framgia/fels_65/contributors","subscribers_url":"https://api.github.com/repos/framgia/fels_65/subscribers","subscription_url":"https://api.github.com/repos/framgia/fels_65/subscription","commits_url":"https://api.github.com/repos/framgia/fels_65/commits{/sha}","git_commits_url":"https://api.github.com/repos/framgia/fels_65/git/commits{/sha}","comments_url":"https://api.github.com/repos/framgia/fels_65/comments{/number}","issue_comment_url":"https://api.github.com/repos/framgia/fels_65/issues/comments{/number}","contents_url":"https://api.github.com/repos/framgia/fels_65/contents/{+path}","compare_url":"https://api.github.com/repos/framgia/fels_65/compare/{base}...{head}","merges_url":"https://api.github.com/repos/framgia/fels_65/merges","archive_url":"https://api.github.com/repos/framgia/fels_65/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/framgia/fels_65/downloads","issues_url":"https://api.github.com/repos/framgia/fels_65/issues{/number}","pulls_url":"https://api.github.com/repos/framgia/fels_65/pulls{/number}","milestones_url":"https://api.github.com/repos/framgia/fels_65/milestones{/number}","notifications_url":"https://api.github.com/repos/framgia/fels_65/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/framgia/fels_65/labels{/name}","releases_url":"https://api.github.com/repos/framgia/fels_65/releases{/id}","created_at":"2015-06-25T02:12:17Z","updated_at":"2015-06-25T02:12:17Z","pushed_at":"2015-06-29T02:13:39Z","git_url":"git://github.com/framgia/fels_65.git","ssh_url":"git@github.com:framgia/fels_65.git","clone_url":"https://github.com/framgia/fels_65.git","svn_url":"https://github.com/framgia/fels_65","homepage":null,"size":0,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":2,"forks":2,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/framgia/fels_65/pulls/4"},"html":{"href":"https://github.com/framgia/fels_65/pull/4"},"issue":{"href":"https://api.github.com/repos/framgia/fels_65/issues/4"},"comments":{"href":"https://api.github.com/repos/framgia/fels_65/issues/4/comments"},"review_comments":{"href":"https://api.github.com/repos/framgia/fels_65/pulls/4/comments"},"review_comment":{"href":"https://api.github.com/repos/framgia/fels_65/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/framgia/fels_65/pulls/4/commits"},"statuses":{"href":"https://api.github.com/repos/framgia/fels_65/statuses/2abfed1434ca8da1121abf50dac49602f4c4482b"}}}}