# 20210303(수)

## 2021-03-03

### 1. 학습 날짜

* 2021-03-03

### 2. 학습 시간

* 09:00 \~ 23:00

### 3. 학습 범위 및 주제

* 백본 view, model, collection
* 루비온레일즈

### 4. 학습 목표

* PR 수정 및 PR 확인

### 5. 학습 정리

* [validator 클래스](https://simian114.gitbook.io/blog/undefined/rubyonrails/validation-1/validator)

### 6. 상세 학습 내용

* 오늘도 많은 학습을 했다.... 오늘 알게된 것들은 `rspec` 을 이용한 모델의 테스트, `validator` 클래스를 이용한 모델의 validation 검사.
* validator 클래스를 이용한 모델의 validation 검사
  * validator 클래스를 이용하면 custom validation 을 편하게 진행할 수 있게 된다.
  * 기존에 custom validation 을 하기 위해서는 validate 를 하고 함수 이름을 적었지만, 이렇게 될 경우 모델 파일내에서 validation 코드를 다 작성하게 되서 모델 파일 자체가 더러워질 수 있다.
  * 따라서 다른 파일 또는 다른 클래스에서 valid 체크를 해야하는데 그 역할을 해주는게 `validator` 클래스.
  * validator 파일을 적절한 곳에 생성하고(만드는 위치에 정답은 없는거 같지만 대부분의 사람들은 app/validators\` 폴더에 만드는 걸 권장한다.
  * 클래스를 작성한 다음 원하는 validation 코드를 작성한다.
  * 이후 model 파일에서는 `validate_with` 문법을 이용해서 validate 검사를 진행한다.

### 7. 오늘 학습 내용에 대한 개인적인 총평

* 이제 정말 끝이 보인다. 어서 끝내자! 즐겁게 코딩하자

### 8. 다음 학습 계획

* war\_request\_create 마무리 및 war\_index\_view 작성하기


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://simian114.gitbook.io/blog/undefined-1/diary/2021/march/20210303.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
