1
1

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 5 years have passed since last update.

Ruby on Rails のselectメソッドで生成されるoptionタグにdisabled属性を追加する

Posted at

はじめに

Ruby on Rails のselectメソッドでされるoptionタグにdisabledを設定したい。

まとめ

第3引数の要素情報を入れている箇所に、ハッシュ形式で追加すれば、設定されました。
他の属性追加についても同様にできました。

<%= f.select :users, User.all.map { |user| [user.name, user.id, {disabled: true}] } %>
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?