13
14

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.

rails check_boxの使い方

Last updated at Posted at 2016-04-06

<%= f.check_box 'カラム名',{},checked_value = "true",unchecked_value = "false" %>

checked_value = "true"

チェックした時にtrueが送られる。

 uncheked_value = "false"

チェックした時にfalseが送られる。

""をつけなければエラーは発生しないが、全部trueになってしまう。

こっちでもok
<%= f.check_box 'カラム名',{}, "true", "false" %>

trueにしたユーザーを取り出すには

Hoge.where({ カラム名: 1 })で取り出すことができる。

13
14
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
13
14

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?