I have a status on one of the models, and want to make it right. Here is a current code version:
self::TEST_NONE = 0
self::TEST_PENDING = 1
self::TEST_DONE = 2
def self.test_status_name name
case name
when self::TEST_NONE
'None'
when self::TEST_PENDING
'Pending'
when self::TEST_DONE
'Done'
else
'None'
end
end
And in the view
<%= Device::test_status_name @device.test_status %>
Which works in general but feels wrong. I want to implement something like a default to_s method for test_status. Additional class could work (not sure how to implement it right), but I don't need and want AR-backed model there, just several constant statuses.