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.

form_forのDB指定

Posted at

はじめに

ネストしていDBのform_for指定方法迷ったのでメモを残します

迷ったところ

= simple_form_for([:admin, campaign, promotion]) do |f|

[:admin, campaign, promotion]が分からなかった

ポイント

form_forの引数は[親、子、孫]となる

ルーティング

namespace :admin do
  resources :campaigns do
   resources :promotions, except: [:index, :show]

以下のようなパスが可能
admin/campaigns/:campaign_id/promotions/new(.:format)

参考資料

ネストさせたルーティングのform_forの使い方

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?