Ruby on rails 载波波形电流路径的NoMethodError
我无法在自定义类中调用CarrierWave current_pathRuby on rails 载波波形电流路径的NoMethodError,ruby-on-rails,ruby,ruby-on-rails-4,ruby-on-rails-5,carrierwave,Ruby On Rails,Ruby,Ruby On Rails 4,Ruby On Rails 5,Carrierwave,我无法在自定义类中调用CarrierWave current_path NoMethodError: private method `try' called for #<CarrierWave::SanitizedFile:0x007fadf259fbf8> def send_letter(letter) data = {} data[:attachment] = File.new("#{letter.template.attachment.current_pa
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
NoMethodError:调用了私有方法“try”#
def发送信函(信函)
数据={}
data[:attachment]=File.new(“#{letter.template.attachment.current_path},'rb')
结束
这发生在letter.template.attachment.current_path调用中,我不明白为什么。在rails控制台中,相同的命令非常有效。。。但是,当我尝试使用rake任务运行它时,使用NoMethodError(如上)失败。如何获取文件的路径而不是当前路径(如果使用CarrierWave上载)。谢谢你的时间
更新
谢谢你的回答。信、模板、礼物真的
信。模板。附件。是否存在-真的
letter.template.attachment.methods.respond_to?(:当前路径)) - 假的
但是letter.template.attachment.methods(有:当前路径)
:cache!,: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
NoMethodError
意味着没有附件
Isletter.template.present?
,Isletter.template.attachment.present?
,并执行letter.template.attachment.methods.Response to?(当前路径)
点击letter.template.attachment.methods
,查看有哪些方法可用于letter.template.attachment
看起来CarrierWave也覆盖了try
-发送信件的跟踪是什么样子的?更新了我的问题