- POST
- ステータスコード:201
- シンボル:created
- レスポンスボディ:新規データ
- PUTおよびPATCH
- ステータスコード:200
- シンボル:ok
- レスポンスボディ:更新後のデータ
- DELETE
- ステータスコード:204
- シンボル:no_content
- 401 :unauthorized あなたが誰だかわからないよ
- 403 :forbidden あなたにこの操作は許可されてないよ
useToast()を使って、以下を実装する
APIのためのテストコードを書く
rspec/requests/
ディレクトリ下にテストを作成するrspec
/* practice_post */
box-sizing: border-box;
position: relative;
width: 330px;
height: 399px;
background: #FFFFFF;
border: 1px solid #0BBBD7;
box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
border-radius: 10px 10px 0px 0px;
/* footer_area */
position: absolute;
width: 330px;
height: 35px;
left: 0px;
top: 365px;
/* footer_box */
box-sizing: border-box;
position: absolute;
width: 330px;
height: 35px;
left: 0px;
top: 365px;
border-top: 1px solid #C4C4C4;
/* like_icon */
position: absolute;
left: 3.94%;
right: 90.61%;
top: 93.73%;
bottom: 2.51%;
border: 1.66667px solid #808080;
/* comment_icon */
position: absolute;
left: 12.73%;
right: 81.82%;
top: 93.48%;
bottom: 2.51%;
background: #808080;
/* dm_icon */
position: absolute;
left: 21.52%;
right: 73.64%;
top: 93.48%;
bottom: 2.51%;
border: 1.25px solid #808080;
/* save_icon */
position: absolute;
left: 91.21%;
right: 4.55%;
top: 93.48%;
bottom: 2.26%;
background: #808080;
/* thoughts_area */
position: absolute;
width: 331px;
height: 125px;
left: 0px;
top: 240px;
/* thoughts_box */
position: absolute;
width: 331px;
height: 125px;
left: 0px;
top: 240px;
/* content */
position: absolute;
width: 300px;
height: 105px;
left: 15px;
top: 250px;
font-family: 'Inter';
font-style: normal;
font-weight: 400;
font-size: 12px;
line-height: 20px;
/* or 167% */
color: #000000;
/* strength_area */
position: absolute;
width: 330px;
height: 40px;
left: 0px;
top: 200px;
/* strength_box */
box-sizing: border-box;
position: absolute;
width: 330px;
height: 40px;
left: 0px;
top: 200px;
background: #FFFFFF;
border-width: 1px 0px;
border-style: solid;
border-color: #C4C4C4;
/* strength_icon */
position: absolute;
width: 165px;
height: 40px;
left: 0px;
top: 200px;
/* strength_vacant_unit */
position: absolute;
left: 34.55%;
right: 55.76%;
top: 30%;
bottom: 30%;
background: #0BBBD7;
/* strength_vacant_unit */
position: absolute;
left: 46.67%;
right: 43.64%;
top: 30%;
bottom: 30%;
background: #0BBBD7;
/* strength_unit */
position: absolute;
left: 58.79%;
right: 31.52%;
top: 30%;
bottom: 30%;
background: #0BBBD7;
/* strength_unit */
position: absolute;
left: 70.91%;
right: 19.39%;
top: 30%;
bottom: 30%;
background: #D9D9D9;
/* strength_unit */
position: absolute;
left: 83.03%;
right: 7.27%;
top: 30%;
bottom: 30%;
background: #D9D9D9;
/* strength_box */
position: absolute;
left: 0%;
right: 0%;
top: 0%;
bottom: 0%;
/* strength_label */
position: absolute;
left: 12.73%;
right: 69.09%;
top: 22.5%;
bottom: 22.5%;
font-family: 'Inter';
font-style: normal;
font-weight: 700;
font-size: 14px;
line-height: 17px;
display: flex;
align-items: center;
color: #808080;
/* weather_place_area */
position: absolute;
width: 330px;
height: 40px;
left: 0px;
top: 160px;
/* weather_place_box */
box-sizing: border-box;
position: absolute;
width: 330px;
height: 40px;
left: 0px;
top: 160px;
background: #FFFFFF;
border-top: 1px solid #C4C4C4;
/* place_area */
position: absolute;
width: 165px;
height: 40px;
left: 165px;
top: 160px;
/* place_label */
position: absolute;
left: 12.73%;
right: 69.09%;
top: 22.5%;
bottom: 22.5%;
font-family: 'Inter';
font-style: normal;
font-weight: 700;
font-size: 14px;
line-height: 17px;
display: flex;
align-items: center;
color: #808080;
/* place_box */
position: absolute;
left: 0%;
right: 0%;
top: 0%;
bottom: 0%;
/* place_icon */
position: absolute;
left: 33.94%;
right: 50.91%;
top: 20%;
bottom: 25%;
/* Vector */
position: absolute;
left: 0%;
right: 0%;
top: 25%;
bottom: 0%;
background: #0BBBD7;
/* wether_area */
position: absolute;
width: 165px;
height: 40px;
left: 0px;
top: 160px;
/* weather_box */
position: absolute;
left: 0%;
right: 0%;
top: 0%;
bottom: 0%;
/* weather_label */
position: absolute;
left: 12.73%;
right: 69.09%;
top: 22.5%;
bottom: 22.5%;
font-family: 'Inter';
font-style: normal;
font-weight: 700;
font-size: 14px;
line-height: 17px;
display: flex;
align-items: center;
color: #808080;
/* weather_icon */
position: absolute;
left: 33.33%;
right: 52.12%;
top: 20%;
bottom: 20%;
/* Vector */
position: absolute;
left: 8.33%;
right: 8.33%;
top: 8.33%;
bottom: 8.33%;
background: #0BBBD7;
/* distance_time_area */
position: absolute;
width: 300px;
height: 80px;
left: 16px;
top: 64px;
/* distance_time_box */
position: absolute;
width: 300px;
height: 80px;
left: 16px;
top: 64px;
background: #0BBBD7;
border-radius: 10px;
/* distance_place_label */
position: absolute;
width: 78px;
height: 18px;
left: 27px;
top: 77px;
font-family: 'Inter';
font-style: normal;
font-weight: 400;
font-size: 12px;
line-height: 15px;
display: flex;
align-items: center;
color: #FFFFFF;
/* distance_area */
position: absolute;
width: 65px;
height: 21px;
left: 27px;
top: 113px;
/* distance */
position: absolute;
width: 46px;
height: 17px;
left: 27px;
top: 113px;
font-family: 'Inter';
font-style: normal;
font-weight: 700;
font-size: 24px;
line-height: 29px;
display: flex;
align-items: center;
color: #FFFFFF;
/* distance_unit */
position: absolute;
width: 19px;
height: 17px;
left: 73px;
top: 117px;
font-family: 'Inter';
font-style: normal;
font-weight: 700;
font-size: 12px;
line-height: 15px;
display: flex;
align-items: center;
color: #FFFFFF;
/* time_area */
position: absolute;
width: 59px;
height: 38px;
left: 162px;
top: 95px;
/* time */
position: absolute;
width: 56px;
height: 18px;
left: 165px;
top: 115px;
font-family: 'Inter';
font-style: normal;
font-weight: 700;
font-size: 16px;
line-height: 19px;
display: flex;
align-items: center;
color: #FFFFFF;
/* time_label */
position: absolute;
width: 30px;
height: 18px;
left: 162px;
top: 95px;
font-family: 'Inter';
font-style: normal;
font-weight: 400;
font-size: 12px;
line-height: 15px;
display: flex;
align-items: center;
text-align: center;
color: #FFFFFF;
/* pace_area */
position: absolute;
width: 56px;
height: 38px;
left: 242px;
top: 95px;
/* pace_time */
position: absolute;
width: 56px;
height: 18px;
left: 242px;
top: 115px;
font-family: 'Inter';
font-style: normal;
font-weight: 700;
font-size: 16px;
line-height: 19px;
display: flex;
align-items: center;
color: #FFFFFF;
/* pace_label */
position: absolute;
width: 39px;
height: 18px;
left: 242px;
top: 95px;
font-family: 'Inter';
font-style: normal;
font-weight: 400;
font-size: 12px;
line-height: 15px;
display: flex;
align-items: center;
text-align: center;
color: #FFFFFF;
/* header */
position: absolute;
width: 330px;
height: 50px;
left: 0px;
top: 0px;
/* header_box */
position: absolute;
width: 329px;
height: 50px;
left: 0px;
top: 0px;
background: #0BBBD7;
/* user_icon */
position: absolute;
width: 35.89px;
height: 36px;
left: 12.96px;
top: 7px;
/* Ellipse 3 */
position: absolute;
width: 35.89px;
height: 36px;
left: 12.96px;
top: 7px;
background: #FFFFFF;
/* Vector */
position: absolute;
left: 4.23%;
right: 85.5%;
top: 2.01%;
bottom: 89.47%;
background: #0BBBD7;
/* date */
position: absolute;
width: 181.45px;
height: 19px;
left: 75.77px;
top: 16px;
font-family: 'Inter';
font-style: normal;
font-weight: 700;
font-size: 16px;
line-height: 19px;
display: flex;
align-items: center;
text-align: center;
color: #FFFFFF;
/* detail_button */
position: absolute;
width: 48.85px;
height: 18px;
left: 281.15px;
top: 8px;
font-family: 'Inter';
font-style: normal;
font-weight: 700;
font-size: 24px;
line-height: 29px;
display: flex;
align-items: center;
text-align: center;
color: #FFFFFF;
フォロー・フォロワー機能を実装する。
フロントエンドを設計する。フロントエンドはReactを使って作る
Container層/Component層をディレクトリから分ける。1ページ1Containerとする。
一旦、以下の4つを作る。ゆくゆくはTeam.jsxなどを作っていきたい。
これらは各ページの最も上部に存在するContainer層で、データを扱う。
中身のボタンやモーダル等は小コンポーネントがレイアウトのみ提供する。
フロントエンドからAPIを叩く部分を考える。一般的にファイルごとに関心を分離するらしい。
そのため、Reactのコンポーネントはあくまでレイアウトやデータを保持することを担当させる。
その場合に、各種APIを呼ぶ部分を関数化して他のファイルに分けることで関心を分離することができる。
コンポーネントファイルの中にAPIを叩く関数を定義してしまうと、他のページから同じAPIを叩きたい場合にコピペするハメになるため、コンポーネントファイル/API関数ファイルを分ける。
Reactの組み込みAPIであるReact Hooksを使う。
APIのURL管理も別ファイルに分ける。RailsでURLがroutes.rbにまとまっているように、フロントエンドでも「ここを参照すればURLがわかる」という状態を明確にする。
urls/index.js
を作成して、ここにAPIのURL文字列を定義していく。
UserモデルのAPIを設計する
PostモデルのAPIを設計する
Postモデルについて、演算処理できる値のカラムが存在するため、DBから消し、post.rbに演算関数を定義する。
演算的に求まる値は整合性観点から持たせない方が望ましいため。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.