I need to reference the numbers in the status
field of the database, which are in the form ENUM
, with the names of my model
.
What is the best way to do this?
models / item.rb
class Item < ActiveRecord::Base
# definir constantes
PUBLICADO = 1
SUSPENSO = 2
SOMETHING = 3
# ???
end
controllers / lista.rb
class ListaController < ApplicationController
# preciso buscar algo assim:
Item.status
Item.status.publicado
Item.status.suspenso
Item.status.something
end