lets say i have a model with enum like this :
class Apt < ActiveRecord::Base
enum apt_status: [ :draft, :publish, :unpublish, :waiting ]
end
and in my controller i load my enum like this :
@apt_statuses = Apt.apt_statuses
it's working fine, but what if i want to load my enum values based on user role? so lets say if i am an admin i want to load all my enum values, and if i am not an admin, i only display 3 enum values
":draft, :unpublish, :waiting"
is it possible? please suggest. many thanks.
Aucun commentaire:
Enregistrer un commentaire