我无法在我的自定义类中调用CarrierWave current_path。CarrierWave的NoMethodError current_path
NoMethodError: private method `try' called for #<CarrierWave::SanitizedFile:0x007fadf259fbf8>
def send_letter(letter)
data = {}
data[:attachment] = File.new("#{letter.template.attachment.current_path}", 'rb')
end
它发生在letter.template.attachment.current_path呼叫,我不明白为什么。在rails控制台中,相同的命令效果很好......但是当我尝试使用rake任务运行它时,它会因NoMethodError(上图)而失败。我如何获取文件的路径而不是current_path(如果使用CarrierWave进行上载)。 Thx为您的时间!
更新 Thx为您的答案。 letter.template.present? - true
letter.template.attachment.present? -true
letter.template.attachment.methods.respond_to(:的current_path) - 假
但letter.template.attachment.methods(有:的current_path)?
:缓存!,: cache_name::retrieve_from_cache !,:cache_stored_file !,:sanitized_file,:model,:mounted_as,:to_s,:length,:size,:path,:read,:content_type,:identifier,:blank ?, current_path
更新我的问题 – likitung