[Git] 직전 commit 내용 수정 (커밋 합치기) 이미 커밋된 내용에 철자 오류 같이 자잘한 실수 가 있을 경우 새로운 커밋을 하기보단 이전 커밋 내용을 변경하는 것이 낫다 (정확히는 새로운 변경을 커밋 후 직전의 커밋과 합치는 것이다). 위의 그림처럼 typo miss 라는 철자 오류가 작성된 Add feature-C라는 커밋이 있다고 가정하자. 우선 이 typo miss 철자 오류를 수정하고 Fix typo 라는 커밋을 합니다. 이제 git rebase 명령어를 통해 Fix typo 커밋과 Add feature-C 커밋을 합치겠습니다 (Fix typo 커밋을 Add feature-C 커밋으로). $ git rebase -i HEAD~2 위의 명령어를 입력하면 최신 브런치(HEAD)를 포함한 두 ..
직전에 작성했던 commit 메시지 수정 직전에 작성했던 커밋 메시지를 수정하고 싶을 때는 git commit --amend 명령어를 사용 $ git commit --ammend 해당 명령어를 실행하면 에이터가 실행되고 방금 입력했던 commit 메시지가 나옵니다. 이를 수정하고 저장, 종료를 해주시면 됩니다. (에디터에 따라 저장 종료 방법은 다릅니다.)(git 에디터를 설정하고 싶으면 git config --global core.editor "vim" 와 같이 설정해주시면 됩니다.) git log --graph 명령어로 확인해보면 정상적으로 commit 메시지가 변경되었음을 확인할 수 있습니다.
routes.rb 에서 nested 라우팅 관리를 하다보면 아래와 같은 경우가 종종 생긴다. resources :messaged doresources :commentsresources :categoriesresources :tagsend resources :posts doresources :commentsresources :categoriesresources :tagsend resources :items doresources :commentsresources :categoriesresources :tagsend comments, categories, tags 와 같은 똑같은 resources 가 중복되어 사용되는 경우 concern method를 이용하여 간단히 나타낼 수 있다. concern :soci..
app/views/users/index.html.erb app/views/users/_user.html.erb app/controllers/users_controller.rbclass UsersController < ApplicationControllerdef create@user = User.new(params[:user])end def destroy@user = User.find(params[:id])@user.destroyendend app/views/create.js.erb$('div#users').append("");... app/views/users/destroy.js.erb$('#').fadeOut();
N+1 Query Problem예를 들어 Client 모델에 관계되어 있는 address 모델에서의 postcode를 뽑을 때 아래와 같은 코드를 사용하면,clients = Client.limit(10)clients.each do |client|puts client.address.postcodeend겉으로는 괜찮아 보이나 11번의 SQL 쿼리를 실행하는 안타까운 점이있다.Client Load (0.1ms) SELECT * FROM "clients" LIMIT 10 Address Load (0.2ms) SELECT * FROM "address" WHERE "client_id" = 1Address Load (0.2ms) SELECT * FROM "address" WHERE "client_id" = 2...A..
기본적인 문법 class PostsController < ApplicationControllerdef edit@post = Post.find(params[:id])if session[:user_id] != @post.user_idflash[:notice] = "Sorry, you can't edit this post"redirect_to post_pathendendend 대체가능한 문법class PostsController < ApplicationControllerdef edit@post = Post.find(params[:id])if session[:user_id] != @post.user_idredirect_to (post_path, notice: "Sorry, you can't edit this p..
기본 Create 문법 t = User.newt.name = "Jinny"t.phone = "01012341234"t.save 대체가능 Create 문법1t. = User.new(name: "Jinny"phone: "01012341234") t.save 대체가능 Create 문법2t = User.create(name: "Jinny", phone: "01012341234") 기본 Update 문법 t = User.find(3)t.name = "Jinny"t.phone = "01012341234"t.save 대체가능 Update 문법1t = User.find(3)t.attributes = {name: "Jinny"phone: "01012341234"} t.save 대체가능 Update 문법2t = User...
- Total
- Today
- Yesterday
- ruby
- CSS
- install
- ruby on rails
- 주식투자
- 한화에어로스페이스
- 국제유가
- 반도체관련주
- 현대차
- Java
- codecademy
- OpenStack
- Message Queue
- 이펙티브 자바
- 프로그래밍
- ubuntu
- 알고리즘
- 흥구석유
- 이수페타시스
- 투자전략
- 자료구조
- rabbitmq
- 삼성전자
- html
- javascript
- 웹프로그래밍
- HBM
- Rails
- 한미반도체
- SK하이닉스
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | |||||
| 3 | 4 | 5 | 6 | 7 | 8 | 9 |
| 10 | 11 | 12 | 13 | 14 | 15 | 16 |
| 17 | 18 | 19 | 20 | 21 | 22 | 23 |
| 24 | 25 | 26 | 27 | 28 | 29 | 30 |
| 31 |
