0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

React + Rails初心者の歩み 〜問題集:中級編〜

Posted at

【中級編(開発可能な中級者向け)】

目標:認証、状態管理、非同期通信、エラーハンドリングの理解。

React(Viteベース)

1. **ログイン状態管理(AuthContext)**を作成して、ログイン中かどうかで表示を切り替えてください。
2. Protected Route(認証されてないとリダイレクト)を実装してください。
react-router-domを使う。
3. 投稿作成ページを作り、Rails APIへPOSTリクエストして投稿できるようにしてください。
4. エラーハンドリングを加えてください。
例えばログイン失敗時に「メールアドレスかパスワードが間違っています」と表示。

Rails(APIモード)

1. ログイン必須のAPIを作成してください。
before_action :require_login を適切に設定。
2. 投稿にユーザーIDを関連付け(belongs_to :user)して、自分の投稿だけ取得できるAPIを作ってください。
3. 簡単な検索機能を実装してください。
/posts?keyword=xxx で、タイトルに「xxx」を含む投稿だけ取得。
4. Serializer(例:ActiveModel::Serializer)を使って、レスポンスを整えてください。
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?