diff --git a/Gemfile.lock b/Gemfile.lock index c708823..48b0c2f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -25,10 +25,10 @@ GEM multi_json (~> 1.3) thread_safe (~> 0.1) tzinfo (~> 0.3.37) - arel (4.0.0) + arel (4.0.1) atomic (1.1.14) bcrypt-ruby (3.0.1) - better_errors (1.0.1) + better_errors (1.1.0) coderay (>= 1.0.0) erubis (>= 2.6.6) binding_of_caller (0.7.2) @@ -47,7 +47,7 @@ GEM celluloid (0.15.2) timers (~> 1.1.0) choice (0.1.6) - coderay (1.0.9) + coderay (1.1.0) coffee-rails (4.0.1) coffee-script (>= 2.2.0) railties (>= 4.0.0, < 5.0) @@ -57,13 +57,13 @@ GEM coffee-script-source (1.6.3) columnize (0.3.6) debug_inspector (0.0.2) - debugger (1.6.2) + debugger (1.6.4) columnize (>= 0.3.1) debugger-linecache (~> 1.2.0) - debugger-ruby_core_source (~> 1.2.3) + debugger-ruby_core_source (~> 1.3.0) debugger-linecache (1.2.0) - debugger-ruby_core_source (1.2.3) - diff-lcs (1.2.4) + debugger-ruby_core_source (1.3.0) + diff-lcs (1.2.5) erubis (2.7.0) execjs (2.0.2) factory_girl (4.2.0) @@ -73,17 +73,17 @@ GEM railties (>= 3.0.0) faker (1.1.2) i18n (~> 0.5) - ffi (1.9.0) + ffi (1.9.3) formatador (0.2.4) - guard (2.1.0) + guard (2.2.5) formatador (>= 0.2.4) listen (~> 2.1) lumberjack (~> 1.0) pry (>= 0.9.12) thor (>= 0.18.1) hike (1.2.3) - i18n (0.6.5) - jbuilder (1.5.2) + i18n (0.6.9) + jbuilder (1.5.3) activesupport (>= 3.0.0) multi_json (>= 1.2.0) jquery-rails (3.0.4) @@ -91,7 +91,7 @@ GEM thor (>= 0.14, < 2.0) json (1.8.1) libv8 (3.16.14.3) - listen (2.1.1) + listen (2.4.0) celluloid (>= 0.15.2) rb-fsevent (>= 0.9.3) rb-inotify (>= 0.9) @@ -100,17 +100,17 @@ GEM mime-types (~> 1.16) treetop (~> 1.4.8) method_source (0.8.2) - mime-types (1.25) - mini_portile (0.5.1) + mime-types (1.25.1) + mini_portile (0.5.2) minitest (4.7.5) mono_logger (1.1.0) multi_json (1.8.2) - nokogiri (1.6.0) + nokogiri (1.6.1) mini_portile (~> 0.5.0) pg (0.15.1) polyglot (0.3.3) - pry (0.9.12.2) - coderay (~> 1.0.5) + pry (0.9.12.4) + coderay (~> 1.0) method_source (~> 0.8) slop (~> 3.4) pry-debugger (0.2.2) @@ -119,7 +119,7 @@ GEM pry-rails (0.3.2) pry (>= 0.9.10) rack (1.5.2) - rack-protection (1.5.0) + rack-protection (1.5.1) rack rack-test (0.6.2) rack (>= 1.0) @@ -139,22 +139,22 @@ GEM rails_12factor (0.0.2) rails_serve_static_assets rails_stdout_logging - rails_serve_static_assets (0.0.1) + rails_serve_static_assets (0.0.2) rails_stdout_logging (0.0.3) railties (4.0.0) actionpack (= 4.0.0) activesupport (= 4.0.0) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) - rake (10.1.0) + rake (10.1.1) rb-fsevent (0.9.3) - rb-inotify (0.9.2) + rb-inotify (0.9.3) ffi (>= 0.5.0) rdoc (3.12.2) json (~> 1.4) - redis (3.0.5) - redis-namespace (1.3.1) - redis (~> 3.0.0) + redis (3.0.6) + redis-namespace (1.4.1) + redis (~> 3.0.4) ref (1.0.5) resque (1.25.1) mono_logger (~> 1.0) @@ -162,8 +162,8 @@ GEM redis-namespace (~> 1.2) sinatra (>= 0.9.2) vegas (~> 0.1.2) - rspec-core (2.14.6) - rspec-expectations (2.14.3) + rspec-core (2.14.7) + rspec-expectations (2.14.4) diff-lcs (>= 1.1.3, < 2.0) rspec-mocks (2.14.4) rspec-rails (2.14.0) @@ -174,7 +174,7 @@ GEM rspec-expectations (~> 2.14.0) rspec-mocks (~> 2.14.0) ruby-graphviz (1.0.9) - sass (3.2.12) + sass (3.2.13) sass-rails (4.0.1) railties (>= 4.0.0, < 5.0) sass (>= 3.1.10) @@ -182,12 +182,12 @@ GEM sdoc (0.3.20) json (>= 1.1.3) rdoc (~> 3.10) - sinatra (1.4.3) + sinatra (1.4.4) rack (~> 1.4) rack-protection (~> 1.4) tilt (~> 1.3, >= 1.3.4) - slop (3.4.6) - sprockets (2.10.0) + slop (3.4.7) + sprockets (2.10.1) hike (~> 1.2) multi_json (~> 1.0) rack (~> 1.0) @@ -208,12 +208,12 @@ GEM treetop (1.4.15) polyglot polyglot (>= 0.3.1) - turbolinks (1.3.0) + turbolinks (2.1.0) coffee-rails tzinfo (0.3.38) - uglifier (2.2.1) + uglifier (2.4.0) execjs (>= 0.3.0) - multi_json (~> 1.0, >= 1.0.2) + json (>= 1.8.0) vegas (0.1.11) rack (>= 1.0.0) will_paginate (3.0.4) diff --git a/README.md b/README.md index 2f8f64a..fc15756 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ You must clone project repository(repo) into your repo by click "Fork" button in Using Terminal to clone (download) project to local ```sh -$ git clone https://github.com/khanhhd/git_trainer.git +$ git clone https://github.com//git_trainer.git ``` Fetch and pull code from develop branch @@ -20,8 +20,8 @@ now, `$ git remote -v`, you will see 2 remote like this: ```sh framgia https://github.com/khanhhd/git_trainer.git (fetch) framgia https://github.com/khanhhd/git_trainer.git (push) -origin https://github.com/kienbt01359/git_trainer.git (fetch) -origin https://github.com/kienbt01359/git_trainer.git (push) +origin https://github.com//git_trainer.git (fetch) +origin https://github.com//git_trainer.git (push) ``` @@ -53,9 +53,49 @@ $ git commit -m "refs #TaskID Name of task" $ git push origin taskID ``` Go to your github's project repo. And send pull request to framgia/develop
- If your code is OK, reviewers will merge, if not, they will adding some comments, and you must fix it again. -And then you will push it again. + And you send the URL of pull-request to reviewers to review it. +## Reviewing a pull-request +When reviewers review a pull-request, there are 3 cases will be happened +### 1. Merge in "first touch" +It means your code is acceptable and it will be merged to develop(branch) of project. +### 2. Have comments +When your code must be modify somewhere, follow by reviews' comments.
+Go to your editor, and modify code as all comments of reviewrs.
+After that, you will commit again, but meld to previous commit. + +```sh +$ git add . +$ git commit --amend (save and close new opend file to edit.) +$ git push origin taskID -f (force new code to existed branch) +``` +And you should notice reviews to review again. If OK -> will merge. If has any comments -> Do this part again. +### 3. Conflicts +Your pushed code has conflict with develop branch of project, so it can not be merged automatically.
+In this case, you should do..
+1. Get newest code from framgia/develop to your develop branch + +```sh +$ git checkout develop +$ git pull framgia develop +``` +2. Checkout to current task and rebase with develop branch + +```sh +$ git checkout taskID +$ git rebase develop +``` +Because of conflicts, so you should contact to member who modified conflict files. And then remove conflicts.
+After resolving all conflicts. + +```sh +$ git add . +$ git rebase --continue +$ git push origin taskID -f +``` + +And you notice for reviewers to check your pull-request is can be merged or not.
+When your pull-request has been merged. Go to redmine and change status of task to Resolved.
This is called a cycle of pull-request. ## Faster commit diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index d8b3d09..8667fca 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,6 +1,13 @@ class ApplicationController < ActionController::Base + + before_action :set_locale + # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. protect_from_forgery with: :exception include SessionsHelper + + def set_locale + I18n.locale = params[:locale] || I18n.default_locale + end end diff --git a/app/controllers/microposts_controller.rb b/app/controllers/microposts_controller.rb index 4f77c91..aee8673 100644 --- a/app/controllers/microposts_controller.rb +++ b/app/controllers/microposts_controller.rb @@ -24,7 +24,7 @@ def micropost_params end def correct_user - @micropost = current_user.microposts.find_by(id: params[:id]) + @micropost = current_user.microposts.find_by(id: params[:id], per_page: 25) redirect_to root_url if @micropost.nil? end end diff --git a/app/controllers/static_pages_controller.rb b/app/controllers/static_pages_controller.rb index c9e0aeb..9418f0a 100644 --- a/app/controllers/static_pages_controller.rb +++ b/app/controllers/static_pages_controller.rb @@ -2,10 +2,7 @@ class StaticPagesController < ApplicationController def home if signed_in? @micropost = current_user.microposts.build if signed_in? - @feed_items = current_user.feed.paginate(page: params[:page]) + @feed_items = current_user.feed.paginate page: params[:page], per_page: 25 end end - - def help - end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index daf5452..f4441fe 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -9,7 +9,7 @@ def index end def show - @microposts = @user.microposts.paginate(page: params[:page]) + @microposts = @user.microposts.paginate page: params[:page], per_page: 25 end def create @@ -48,14 +48,14 @@ def destroy def following @title = "Following" @user = User.find(params[:id]) - @users = @user.followed_users.paginate(page: params[:page]) + @users = @user.followed_users.paginate(page: params[:page], per_page: 25) render 'show_follow' end def followers @title = "Followers" @user = User.find(params[:id]) - @users = @user.followers.paginate(page: params[:page]) + @users = @user.followers.paginate(page: params[:page], per_page: 25) render 'show_follow' end diff --git a/app/views/shared/_micropost_form.html.erb b/app/views/shared/_micropost_form.html.erb index e2c2bf8..b1e25b0 100644 --- a/app/views/shared/_micropost_form.html.erb +++ b/app/views/shared/_micropost_form.html.erb @@ -1,7 +1,7 @@ <%= form_for(@micropost) do |f| %> <%= render 'shared/error_messages', object: f.object %>
- <%= f.text_area :content, placeholder: "Compose new micropost..." %> + <%= f.text_area :content, placeholder: t(:compose_new_micropost) << "..." %>
- <%= f.submit "Post", class: "btn btn-large btn-primary" %> + <%= f.submit t(:post), class: "btn btn-large btn-primary" %> <% end %> diff --git a/app/views/shared/_user_info.html.erb b/app/views/shared/_user_info.html.erb index aeda014..75923a4 100644 --- a/app/views/shared/_user_info.html.erb +++ b/app/views/shared/_user_info.html.erb @@ -3,7 +3,7 @@ <%= current_user.name %> - <%= link_to "view my profile", current_user %> + <%= link_to t(:view_my_profile), current_user %> <%= pluralize(current_user.microposts.count, "micropost") %> diff --git a/app/views/static_pages/help.html.erb b/app/views/static_pages/help.html.erb index 96bd129..e7f91e7 100644 --- a/app/views/static_pages/help.html.erb +++ b/app/views/static_pages/help.html.erb @@ -1,18 +1,2 @@ -<% provide(:title, "Help") %> - - - - Ruby on Rails Tutorial Sample App | <%= yield(:title) %> - - -

Help

-

- Get help on the Ruby on Rails Tutorial at the - Rails Tutorial help page. - To get help on this sample app, see the - Rails Tutorial book. -

- - - -

Find me in app/views/static_pages/help.html.erb

+

Help

+Day la trang help . \ No newline at end of file diff --git a/app/views/static_pages/home.html.erb b/app/views/static_pages/home.html.erb index f83b1d5..9c4590f 100644 --- a/app/views/static_pages/home.html.erb +++ b/app/views/static_pages/home.html.erb @@ -12,21 +12,19 @@
-

Micropost Feed

+

<%=t :micropost_feed %>

<%= render 'shared/feed' %>
<% else %>
-

Welcome to the Sample App

+

<%=t :home_welcom_message %>

- This is the home page for the Ruby on Rails Tutorial sample application. + <%=t :home_description_message %>

-

Test for Git

- - <%= link_to "Dang ky!", signup_path, + <%= link_to t(:home_register_message), signup_path, class: "btn btn-large btn-primary" %>
diff --git a/app/views/users/_user.html.erb b/app/views/users/_user.html.erb index 2a599c8..d48a1ae 100644 --- a/app/views/users/_user.html.erb +++ b/app/views/users/_user.html.erb @@ -1,8 +1,5 @@
  • -<%= gravatar_for user %> -<%= link_to user.name, user %> -<% if current_user.admin? && !current_user?(user) %> - | <%= link_to "delete", user, method: :delete, - data: { confirm: "You sure?" } %> - <% end %> -
  • + <%= gravatar_for user %> + <%= link_to user.name, user %> + <%= user.email %> + \ No newline at end of file diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb index 4afe288..4f81e3d 100644 --- a/app/views/users/edit.html.erb +++ b/app/views/users/edit.html.erb @@ -1,26 +1,22 @@ -<% provide(:title, "Edit user") %> -

    Cap nhat thong tin ca nhan

    +<% provide(:title, "Thay đổi thông tin tài khoản") %>
    <%= form_for(@user) do |f| %> <%= render 'shared/error_messages', object: f.object %> - <%= f.label :name %> + <%= f.label :name, "Tên tài khoản" %> <%= f.text_field :name %> - <%= f.label :email %> + <%= f.label :email, "Địa chỉ Email" %> <%= f.text_field :email %> - <%= f.label :password %> + <%= f.label :password, "Mật khẩu" %> <%= f.password_field :password %> - <%= f.label :password_confirmation, "Confirm Password" %> + <%= f.label :password_confirmation, "Nhập lại mật khẩu" %> <%= f.password_field :password_confirmation %> - <%= f.submit "Thay doi", class: "btn btn-large btn-primary" %> + <%= f.submit "Cập nhật", class: "btn btn-large btn-primary" %> <% end %> - - <%= gravatar_for @user %> - change
    diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index 0733ef8..e87f972 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -6,7 +6,7 @@ <%= gravatar_for @user %> <%= @user.name %>
      - Email: <%= @user.emai%> + Email: <%= @user.email %>

    I'm tired

    diff --git a/comment b/comment new file mode 100644 index 0000000..b3f838d --- /dev/null +++ b/comment @@ -0,0 +1 @@ +cmt = amend diff --git a/config/locales/en.yml b/config/locales/en.yml index 0653957..170a7f7 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -21,3 +21,10 @@ en: hello: "Hello world" + home_welcom_message: "Welcome to the Sample App" + home_description_message: "This is the home page for the Ruby on Rails Tutorial sample application." + home_register_message: "Register" + view_my_profile: "View my profile" + post: "Post" + compose_new_micropost: "Compose new micropost" + micropost_feed: "Micropost Feed" diff --git a/config/locales/vi.yml b/config/locales/vi.yml new file mode 100644 index 0000000..82c704a --- /dev/null +++ b/config/locales/vi.yml @@ -0,0 +1,8 @@ +vi: + home_welcom_message: "Chào mừng bạn đến với Sample App" + home_description_message: "Đây là trang chủ cho ứng dụng ví dụ từ Ruby on Rails Tutorial." + home_register_message: "Đăng ký" + view_my_profile: "Xem profile của tôi" + post: "Đăng" + compose_new_micropost: "Soạn một bài mới" + micropost_feed: "Thêm bài viết" \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index cc790e6..d1d4eba 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -8,8 +8,8 @@ resources :microposts, only: [:create, :destroy] resources :relationships, only: [:create, :destroy] root 'static_pages#home' - match '/help', to: 'static_pages#help', via: 'get' match '/about', to: 'static_pages#about', via: 'get' + match '/help', to: 'static_pages#help', via: 'get' match '/signup', to: 'users#new', via: 'get' match '/signin', to: 'sessions#new', via: 'get' match '/signout', to: 'sessions#destroy', via: 'delete' diff --git a/db/migrate/20131227093513_add_phone_to_users.rb b/db/migrate/20131227093513_add_phone_to_users.rb new file mode 100644 index 0000000..7f94bae --- /dev/null +++ b/db/migrate/20131227093513_add_phone_to_users.rb @@ -0,0 +1,5 @@ +class AddPhoneToUsers < ActiveRecord::Migration + def change + add_column :users, :phone, :string + end +end diff --git a/db/migrate/20131227093911_change_phone_format_in_users.rb b/db/migrate/20131227093911_change_phone_format_in_users.rb new file mode 100644 index 0000000..ad4b253 --- /dev/null +++ b/db/migrate/20131227093911_change_phone_format_in_users.rb @@ -0,0 +1,5 @@ +class ChangePhoneFormatInUsers < ActiveRecord::Migration + def change + change_column :users, :phone, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index 1d7b7a0..29493d0 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20131003023553) do +ActiveRecord::Schema.define(version: 20131227093911) do create_table "microposts", force: true do |t| t.string "content" @@ -38,9 +38,10 @@ t.string "email" t.string "password_digest" t.string "remember_token" - t.boolean "admin", default: false + t.boolean "admin", default: false t.datetime "created_at" t.datetime "updated_at" + t.integer "phone", limit: 255 end add_index "users", ["remember_token"], name: "index_users_on_remember_token"