I am working on a Ruby on Rails project at the moment and ran across an interesting issue in ActiveAdmin. When I attempt to show an entity by id in a ActiveAdmin.register file, I would receive an error:
NoMethodError in MyEntity#show undefined method `humanize' for nil:NilClass
I was lucky enough to get an Application Trace telling me the line to look at:
row(_nil) { "#{MyEntity.education_from_date} - #{MyEntity.education_thru_date}"}
Note: The formatting javascript removes the parameter "nil". Assume "_nil" is "nil".
Digging into to the database I discovered that the properties in the database were null, so I figured perhaps that was the issue (shouldn't be, but verifying this would be easy). I populated the fields, but the exception remained.
After some additional pondering, I looked at the nil parameter. There were other occurrences of this following that line, so I didn't think this would be fruitful. With a lack of other possible solutions, I pursued this farther. The row was supposed to not display a label, but just display the value. My first attempt was to change nil to "", but the exception remained. Not to be deterred, I attempted " " and that fixed my issue.
row(" ") { "#{MyEntity.education_from_date} - #{MyEntity.education_thru_date}"}
No comments:
Post a Comment