Skip to content

Instantly share code, notes, and snippets.

@attenzione
attenzione / boolean_value.rb
Last active October 14, 2026 11:00
Ruby: casting to boolean value
module BooleanValue
# https://github.com/rails/rails/blob/main/activemodel/lib/active_model/type/boolean.rb
FALSE_VALUES = [
false, 0,
'0', :'0',
'f', :f,
'F', :F,
'false', :false, # rubocop:disable Lint/BooleanSymbol
'FALSE', :FALSE,
'off', :off,

There are several types of relationships.

  • OneToMany
  • OneToOne
  • OneToNone
  • ManyToNone

A OneToMany relationship has a Set of members and a link to the belongsTo. Each member and the belongsTo has a link back to the relationship. The member links can change.

A ManyToNone relationship has a Set of members and a link to the belongsTo. The belongsTo has a link back to the relationship. The link doesn't change.