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?

More than 1 year has passed since last update.

resourcesのネスト

Last updated at Posted at 2022-07-18

resourcesのネストをするケース

• モデル間で関連付けが設定されており、親子両方の情報をURLに含めたい場合

routes.rb

resources :boards do
  resources :comments
end
# => /boards/:board_id/comments/:comment_id といったURLが得られる

このようにする場合

#model/board.rb
has_many :comments

#model/comment.rb
belongs_to :board

と関連付けてある必要がある。

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?