0

経由でアイテムをレンダリングします<%= render @items%>

移行を追加しましたAddCatIdToItems cat_id:string

Cat_id: testA、testB、testC。

特定の id を持つアイテムのみをレンダリングするにはどうすればよいtestAですか?

例えば:<&= @items.where(:cat_id => '1')&>

シード ファイルを使用してアイテムを設定します。例えば:

Tag.create([
            { name: 'example' },
            { name: 'example2' },
            { name: 'example3' }
           ])

cat_id をそれに渡すにはどうすればよいですか?

{ name: 'example', cat_id:1 }働いていますか?

4

1 に答える 1