views:

76

answers:

1

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.

+2  A: 
class Symbol
  def to_c
    self.to_s.camelize.constantize
  end
end

:monkey.to_c
Dutow
yeah, fair enough!
inglesp
I believe I've just seen monkey patching defined :)
John Munsch