Open danielb2 opened 1 year ago
ok it's because I didn't have the enum configured in the model. but maybe there's some better way than this crash. database is postgresql
I ran into a variation of this (undefined method 'map' for an instance of String
) that also stems from the changes to add filter_operators
.
Instead of having a database-only enum, I had a method defined def self.field_name_enum; [...]; end
. Starting with rails admin 3.1.0 that method was no longer being automatically found by enum_method
. It seems like the default enum_method
logic is now called in a context where binding[:object]
is nil. As a result method_name
falls back to the field name. The enum
method then calls field_name on the record, returning the enum value for the record instead of the list of allowed enum values.
In this case a workaround was to explicitly configure enum_method :field_name_enum
.
Describe the bug
Trying to access view of table after adding new columns one with enum type
Reproduction steps
Expected behavior Display board as usual
Additional context
rails
version: 7.0.4.3rails_admin
version: 3.1.2Full stack trace
2023-04-20 10:08:52.633270 F [78109:puma srv tp 002 thread_local_var.rb:93] Rails -- Exception: ActionView::Template::Error: undefined method `map' for nil:NilClass /Users/daniel/.asdf/installs/ruby/3.2.1/lib/ruby/gems/3.2.0/gems/rails_admin-3.1.2/lib/rails_admin/config/fields/types/enum.rb:14:in `block in