Is there a method in Rails that converts a symbol to a constant? I want to be able to do something like
:monkey.to_constant #=> Monkey
At the moment I have to do
:monkey.to_s.camelize.constantize
which is a bit of a mouthful.
Is there a method in Rails that converts a symbol to a constant? I want to be able to do something like
:monkey.to_constant #=> Monkey
At the moment I have to do
:monkey.to_s.camelize.constantize
which is a bit of a mouthful.
class Symbol
def to_c
self.to_s.camelize.constantize
end
end
:monkey.to_c