LoginSignup
0
1

More than 5 years have passed since last update.

collection_selectのform_for内での使い方

Posted at

テキストを投稿させる際にフォーム内でジャンルを選ばせる時にcollection_selectを使ったので
すごく簡単にまとめて見た

qiita.rb
<%= f.collection_select :genre_id, Genre.all, :id, :name %>

<%= f.collection_select (オブジェクト名),プロパティ, オブジェクトの配列, value属性の項目, text %>

第一引数のオブジェクト名はform_forの時は必要ない

参考
「rails」f.collection_selectの使用方法

0
1
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
1