Pergunta

This is what I'm trying:

require "active_support"

desc "test"
task :foo => [:environment] do
  parse(:categories) do |hash|
    # cleanup name
    hash[:name] = titlecase(hash[:name])
    # ...
  end
end

This is the error I'm getting:

undefined method `titlecase' main:Object

I've also tried:

ActiveSupport::Inflector::titlecase(hash[:name])

Results in this error:

undefined method `titlecase' ActiveSupport::Inflector:Module

Foi útil?

Solução

try

hash[:name] = hash[:name].titlecase

instead of what you are trying. it worked for me.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top