RubyGems Navigation menu

formtastic_tristate_radio 0.2.3

Have 3-state radiobuttons instead of a 2-state checkbox for your Boolean columns which can store NULL. What the gem does? 1. Provides a custom Formtastic input type `:tristate_radio` which renders 3 radios (“Yes”, “No”, “Unset”) instead of a checkbox (only where you put it). 1. Teaches Rails recognize `"null"` and `"nil"` param values as `nil`. See “[How it works](#how-it-works)” ☟ section for technical details on this. 1. Encourages you to add translations for ActiveAdmin “status tag” so that `nil` be correctly translated as “Unset” instead of “False”. Does not change controls, you need to turn it on via `as: :tristate_radio` option. By defenition Boolean values have 2 states: True & False. However, if you store a Boolean value in a database column with no `NOT NULL` restriction, it aquires a 3<sup>d</sup> possible state: `null`. Some may consider this practice questionable — I don’t think so. In real life you always have a case when the answer to your question may be only “yes” or “no”, but you don’t know the answer yet. Using a string type column, storing there `"yes"`, `"no"` and `"unset"` + using a state machine + validations — feels overkill to me.

Gemfile:
=

インストール:
=

バージョン履歴:

  1. 0.2.8 October 04, 2024 (13.5KB)
  2. 0.2.7 June 10, 2022 (13.5KB)
  3. 0.2.6 June 09, 2022 (13KB)
  4. 0.2.5 November 09, 2021 (24.5KB)
  5. 0.2.4 November 09, 2021 (13KB)
  6. 0.2.3 November 09, 2021 (13.5KB)
全てのバージョンを表示(全10件)

Runtime依存関係 (2):

formtastic >= 3, < 5
rails >= 4, < 7

Development依存関係 (2):

rspec ~> 3
yard >= 0.9.20, < 1

所有者:

プッシュ者:

作者:

  • Sergey Pedan

SHA 256チェックサム:

=

累計ダウンロード数 10,801

このバージョンのみ 1,218

このバージョンがリリースされたのは:

ライセンス:

MIT

必要なRubyのバージョン: >= 2.4.0

リンク: