collection_selectのform_for内での使い方
661 ワード
テキストを投稿させる際にフォーム内でジャンルを選ばせる時にcollection_selectを使ったので
すごく簡単にまとめて見た
形
qiita.rb
<%= f.collection_select :genre_id, Genre.all, :id, :name %>
<%= f.collection_select (オブジェクト名),プロパティ, オブジェクトの配列, value属性の項目, text %>
第一引数のオブジェクト名はform_forの時は必要ない
Author And Source
この問題について(collection_selectのform_for内での使い方), 我々は、より多くの情報をここで見つけました https://qiita.com/tanaka7014/items/efbba49e9b9d27feb5d0著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .