jyl*_*li7 1 ruby-on-rails amazon-s3 paperclip carrierwave
所以我正在使用载波直接,我正处于需要更新上传器对象的"key"属性的位置.这是文档中的相关行:
上传到S3后,您需要使用与new_user_url对应的控制器操作中返回的密钥更新上传器对象:
@uploader.update_attribute :key, params[:key]
Run Code Online (Sandbox Code Playgroud)
问题是我的@uploader对象没有update_attribute方法.实际上,当我查看@uploader对象上的所有方法时,我看到的方法如key()和key =(),但没有update_attribute.
知道发生了什么事吗?我是否错过了为使update_attribute方法可用而需要执行的一些设置步骤?
小智 7
我通过在模型上调用update_attribute而不是上传器来实现它.在下面剪切了@uploader,CarrierWave :: Uploader :: Base和@video的子类是模型.
def upload
@uploader = Video.new.asset
@uploader.success_action_redirect = videos_upload_successful_url
end
def upload_successful
@video = Video.new
@video.update_attribute :key, params[:key] # different than documentation!!
@video.save
end
Run Code Online (Sandbox Code Playgroud)
这似乎与文档相反,文档以您尝试的方式记录.
| 归档时间: |
|
| 查看次数: |
780 次 |
| 最近记录: |