Rails 5 on aws c9(31)
-
N11. avatar 이미지 업로드 : 썸네일 사용
github.com/comp-er/noar 최종버전 comp-er/noar Contribute to comp-er/noar development by creating an account on GitHub. github.com 유저 아바타 이미지를 올려보자 post랑 다르게 썸네일을 생성하도록 해 볼것이다. 회원가입, 회원정보 수정시에 이미지를 올리도록 해야한다. views/registrations/new.html.erb Sign up ... ... views/registrations/edit.html.erb Edit ... ... controllers/application_controller.rb class ApplicationController < ActionController::Base protect..
2020.07.05 -
N10. post 이미지 업로드 Carrierwave 적용
파일업로드를 담당하는 carrierwave 세팅을 해보자. 이미지를 업로드해 아바타 이미지 추가, 포스트 이미지 추가가 가능하다. gemfile에 gem 'carrierwave' 추가 콘솔에 ubuntu:~/environment/noar (master) $ bundle The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, ru..
2020.07.05 -
N9. 댓글 기능 구현
ubuntu:~/environment $ ls README.md hello_world noar ubuntu:~/environment $ cd noar ubuntu:~/environment/noar (master) $ rails g controller Comments Running via Spring preloader in process 3276 create app/controllers/comments_controller.rb invoke erb create app/views/comments invoke test_unit create test/controllers/comments_controller_test.rb invoke helper create app/helpers/comments_helper.rb ..
2020.07.05 -
N8. 좋아요 기능 UI 구현하기
views/posts/index.html.erb에서 post와 관련된 부분이 너무 비대해진걸 볼 수 있다. 이럴 때 코드를 partial로 빼면 좋다. (이하는 너무 비대해진 코드) 이메일 : 올린 글 개수 : 글 쓰기 좋아요 댓글 달기 이하를 잘라내서 _post.html.erb로 따로 만들자 좋아요 댓글 달기 이메일 : 올린 글 개수 : 글 쓰기 class User < ApplicationRecord # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable ... #User 모델의 한 객체에 대해 특정 글에 대한 좋아요 유무를 확인 de..
2020.07.05 -
N7. N:N관계
1:N 이 가장 많이 쓰이는 관계이다 N:N관계도 있다. 이는 게시물과 #해시태그의 관계가 있을 수 있다 하나의 게시물은 여러개의 해시태그를 가질 수 있고 해시태그는 여러 게시물을 가질 수 있다. 게시물의 좋아요도 그렇게 구현할 수 있다. User ← 1:N → Like ← N:1 → Post 두개의 태이블을 Join하면 N:N을 얻을 수 있다. (join table) 하나의 유저가 여러개의 포스트를 좋아요 할 수 있고 하나의 포스트가 여러개의 좋아요를 받을 수 있다. 이럴 경우 User has many liked_posts through likes Post has many liked_users through likes ubuntu:~/environment/noar (master) $ rails g mo..
2020.07.05 -
N6. Post 수정과 삭제
이번엔 수정과 삭제를 구현해보자. 이메일 : 올린 글 개수 : 글 쓰기 좋아요 댓글 달기 views/posts/edit.html.erb 추가 (edit 에는 내용이 차 있어야 한다) 수정하기
2020.07.05