Reputation: 67
I have the following model:
class FileInfo < ActiveRecord::Base
STATUS = {:UNAPPROVED => 1, :APPROVED => 2, :PROCESSED => 3 }
attr_accessible :id, :status
validates :status, :inclusion => {:in => STATUS.values}
end
I want to access STATUS
hashmap in another class:
class FileInfoObserver < ActiveRecord::Observer
def after_save(file_info)
if file_info.status.eql? 2 //HERE, I want to access STATUS[:APPROVED]
// Some logic
end
end
end
How do I do that?
Upvotes: 0
Views: 25
Reputation: 14038
FileInfo::STATUS
to access the hash itself, it's a class method so call it on the class.
Upvotes: 2