I just updated my rails app from ruby 2.7.0 to 3.2.2 and a following code:
class TemplateField < ApplicationRecord
enum group: {
'primary': 'primary',
'secondary': 'secondary',
'auxiliary': 'auxiliary',
'header': 'header',
'back': 'back',
'unassigned': 'unassigned'
}
end
class Template < ApplicationRecord
TemplateField.groups.each do |_key, val|
has_many "fields_#{val.pluralize}".to_sym #...
end
end
Broke with a following message:
NoMethodError:
undefined method `groups' for TemplateField:Class
Basically, also calling TemplateField.groups
directly in console produces the same error. Does anything changed between ruby 2.7 and 3.2 that I should be aware of?
In my particular case, that was caused by outdated sorbet-rails
dependency. Running bundle update sorbet sorbet-rails
fixed the issue for me.