Come chiamare il metodo ActiveSupport all'interno task rake?
-
01-10-2019 - |
Domanda
Questo è quello che sto cercando:
require "active_support"
desc "test"
task :foo => [:environment] do
parse(:categories) do |hash|
# cleanup name
hash[:name] = titlecase(hash[:name])
# ...
end
end
Questo è l'errore che sto ricevendo:
metodo non definito `Titlecase' principale: Oggetto
Ho anche provato:
ActiveSupport::Inflector::titlecase(hash[:name])
I risultati in questo errore:
metodo non definito `Titlecase' ActiveSupport :: inflettore: Modulo
Soluzione
try
hash[:name] = hash[:name].titlecase
invece di quello che si sta cercando. ha funzionato per me.
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow