Skip to content

Instantly share code, notes, and snippets.

@YumaInaura
Created June 8, 2024 04:05
Show Gist options
  • Save YumaInaura/bc5d2ad540a116a554bc4173cf057773 to your computer and use it in GitHub Desktop.
Save YumaInaura/bc5d2ad540a116a554bc4173cf057773 to your computer and use it in GitHub Desktop.
Rails + Enumerize Troulble – ActiveRecord Instance returns nil But Datable data value is exists

Trouble

Example Class

class Example < ApplicationRecord
  extend Enumerize

  enumerize :name, in: %i[alice bob carol]
end

Then table column value is invalid as Enumerize ActiveRecord instance returns nil

Examinee.find_by(name: 'david').name # nil

Cause

This Enumerize Trouble Remove enumerize line in Model then it fixed.

Examinee.find_by(name: 'david').name # david
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment