Updating users
{{ resolvedDiscussionCount }}/{{ discussionCount }} {{ resolvedCountText }} resolved
-
1 1 module UsersHelper 2 2 # Returns the Gravatar for the given user. 3 def gravatar_for(user, size: 80) 3 def gravatar_for(user,options={ size: 80}) -
Master
coding convention
-
-
-
app/views/users/edit.html.erb 0 → 100644
1 <!-- <% provide(:title, "Edit user") %> -
Master
không comment code, không dùng thì xóa đi
-
-
-
app/views/users/edit.html.erb 0 → 100644
10 <%= f.label :email %> 11 <%= f.email_field :email, class: "form-control" %> 12 <%= f.label :password %> 13 <%= f.password_field :password, class: "form-control" %> 14 <%= f.label :password_confirmation, "Confirmation" %> 15 <%= f.password_field :password_confirmation, class: "form-control" %> 16 <%= f.submit "Save changes", class: "btn btn-primary" %> 17 <% end %> 18 19 <div class="gravatar_edit"> 20 <%= gravatar_for @user %> 21 <a href="http://gravatar.com/emails" target="_blank">change</a> 22 </div> 23 </div> 24 </div> --> 25 <% provide(:title, 'Edit user') %> -
Master
double quote
-
-
-
1 <% provide(:title, "Sign up") %> 1 <!-- <% provide(:title, "Sign up") %> -
Master
code không còn dùng đến thì xóa đi
-
-
-
1 # This file should contain all the record creation needed to seed the database with its default values. 2 # The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup). 3 # 4 # Examples: 5 # 6 # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) 7 # Character.create(name: 'Luke', movie: movies.first) 1 User.create!(name: "Example User",email: "example@railstutorial.org",password:"foobar",password_confirmation: "foobar",admin: true) -
Master
indent
-
-
-
Toggle commit list
-
-
-
Toggle commit list
-
-
-
1 # This file should contain all the record creation needed to seed the database with its default values. 2 # The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup). 3 # 4 # Examples: 5 # 6 # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) 7 # Character.create(name: 'Luke', movie: movies.first) 1 User.create!(name: "Example User", email: "example@railstutorial.org", password:"foobar", password_confirmation: "foobar") 2 99.times do |n| 3 name = Faker::Name.name 4 email = "example-#{n+1}@railstutorial.org" 5 password = "password" 6 User.create!(name: name, email: email, password:password, password_confirmation: password) -
Master
indent
-
-
-
-
-
test/integration/users_edit_test.rb 0 → 100644
1 require "test_helper" 2 3 class UsersEditTest < ActionDispatch::IntegrationTest 4 5 def setup 6 @user = users(:michael) 7 end 8 9 test "unsuccessful edit" do 10 log_in_as(@user) 11 get edit_user_path(@user) 12 assert_template "users/edit" 13 patch user_path(@user), params: { user: { name: "",email: "foo@invalid",password: "foo",password_confirmation: "bar" } } -
MasterEdited by Son Do Hong
xem lại coding convention của toàn bộ file này, dấu space thiếu ở đâu, thừa ở đâu
-
-
-
27 log_in_as(@other_user) 28 patch user_path(@user), params: { user: { name: @user.name,email: @user.email } } 29 assert flash.empty? 30 assert_redirected_to root_url 31 end 32 33 test "should redirect update when not logged in" do 34 patch user_path(@user), params: { user: { name: @user.name,email: @user.email } } 35 assert_not flash.empty? 36 assert_redirected_to login_url 37 end 38 39 test "should not allow the admin attribute to be edited via the web" do 40 log_in_as(@other_user) 41 assert_not @other_user.admin? 42 patch user_path(@other_user), params: {user:{ password: @other_user.password,password_confirmation: @other_user.password, admin: true } } -
Master
space với dấu
{và dấu,không đúng -
-
-
-
-
-
-
-
test/integration/users_edit_test.rb 0 → 100644
22 email = "foo@bar.com" 23 patch user_path(@user), params: { user: { name: name, email: email, password: "", password_confirmation: "" } } 24 assert_not flash.empty? 25 assert_redirected_to @user 26 @user.reload 27 assert_equal name, @user.name 28 assert_equal email, @user.email 29 end 30 31 test "successful edit with friendly forwarding" do 32 get edit_user_path(@user) 33 log_in_as(@user) 34 assert_redirected_to edit_user_url(@user) 35 name = "Foo Bar" 36 email = "foo@bar.com" 37 patch user_path(@user), params: { user: { name: name, email: email, password:"", password_confirmation: "" } } -
Master
vẫn thiếu space
-
-
-
27 log_in_as(@other_user) 28 patch user_path(@user), params: { user: { name: @user.name, email: @user.email } } 29 assert flash.empty? 30 assert_redirected_to root_url 31 end 32 33 test "should redirect update when not logged in" do 34 patch user_path(@user), params: { user: { name: @user.name, email: @user.email } } 35 assert_not flash.empty? 36 assert_redirected_to login_url 37 end 38 39 test "should not allow the admin attribute to be edited via the web" do 40 log_in_as(@other_user) 41 assert_not @other_user.admin? 42 patch user_path(@other_user), params: {user:{ password: @other_user.password, password_confirmation: @other_user.password, admin: true } } -
Master
{user:{=>{ user: { -
Master
đọc lại ruby style guide: https://github.com/rubocop-hq/ruby-style-guide#spaces-braces
-
-
-
2 # The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup). 3 # 4 # Examples: 5 # 6 # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) 7 # Character.create(name: 'Luke', movie: movies.first) 1 User.create!(name: "Example User", 2 email: "example@railstutorial.org", 3 password: "foobar", 4 password_confirmation: "foobar") 5 6 99.times do |n| 7 name = Faker::Name.name 8 email = "example-#{n+1}@railstutorial.org" 9 password = "password" 10 User.create!(name: name, -
Master
dư space
-
-
-
1 # This file should contain all the record creation needed to seed the database with its default values. 2 # The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup). 3 # 4 # Examples: 5 # 6 # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) 7 # Character.create(name: 'Luke', movie: movies.first) 1 User.create!(name: "Example User", -
Master
dư 1 space
-
-
-
3 4 4 <div class="row"> 5 5 <div class="col-md-6 col-md-offset-3"> 6 <%= form_for(@user) do |f| %> 7 <%= render "shared/error_messages" %> 8 <%= f.label :name %> 9 <%= f.text_field :name, class: "form-control" %> 10 <%= f.label :email %> 11 <%= f.email_field :email, class: "form-control" %> 12 <%= f.label :password %> 13 <%= f.password_field :password, class: "form-control" %> 14 <%= f.label :password_confirmation, "Confirmation" %> 15 <%= f.password_field :password_confirmation, class: "form-control" %> 16 <%= f.submit "Create my account", class: "btn btn-primary" %> 17 <% end %> 6 <%= render 'form' %> -
Master
double quote
-
-
-
app/views/users/index.html.erb 0 → 100644
1 <% provide(:title, 'All users') %> -
Master
double quote
-
-
-
app/views/users/_user.html.erb 0 → 100644
1 <li> 2 <%= gravatar_for user, size: 50 %> 3 <%= link_to user.name, user %> 4 <% if current_user.admin? && !current_user?(user) %> 5 | <%= link_to "delete", user, method: :delete,data: {confirm: "You sure?" } %> -
Master
Xem lại ruby style guide https://github.com/rubocop-hq/ruby-style-guide#spaces-braces
-
-
-
-
1 1 class UsersController < ApplicationController 2 before_action :logged_in_user, only: [:index, :edit, :update,:destroy] -
-
1 # Place all the behaviors and hooks related to the matching controller here. 2 # All this logic will automatically be available in application.js. -
Master
file này ko liên quan đến chap này, xóa khỏi merge request
-
-
-
1 // Place all the styles related to the AccountActivations controller here. -
Master
file này ko liên quan đến chap này, xóa khỏi merge request
-
-
-
-
-
merged
Toggle commit list