Gem 关于又拍云的使用,undefined method 'uploader_secure_token'

stephen · 2012年11月27日 · 最后由 leslin123 回复于 2014年03月17日 · 5151 次阅读

使用又拍云, 参考@huacnlee

http://huacnlee.com/blog/rails-app-image-store-with-carrierwave-upyun/#use-carrierwave

出现 undefined method 'uploader_secure_token' 是这里

def filename
    if super.present?
      model.uploader_secure_token ||= SecureRandom.uuid.gsub("-","")
      Rails.logger.debug("(BaseUploader.filename) #{model.uploader_secure_token}")
      "#{model.uploader_secure_token}.#{file.extension.downcase}"
    end
  end

请问应该怎么解决!

在 Model 里面补上

class User < ActiveRecord::Base
  attr_accessor :upload_secure_token

  ...
end

@huacnlee 出现这个错误了 undefined method `attract_accessor` for

attr_accessor,我手机上写错了

@huacnlee 谢谢,这个问题有遇到嘛?

RestClient::unauthorized in AccountsController#update
401 Unautorized

提交表单的时候

Unautorized 是验证失败

是 devise 问题,还是 UPYUN 的验证呢?没用 UPYUN 的时候,没这个错误出现的

UpYun 的呀

#7 楼 @stephen 问下你的 401 Unautorized 这个问题解决了吗?我也遇到这个问题了。。。

@shanks 是验证问题,你看看你的空间是否开启了允许外链

#10 楼 @stephen 多谢,已经解决了

@stephen @shanks @huacnlee 大侠们求救,我也出现了 401 错误,但是我禁止外链,允许外链都出现了这个问题

RestClient::Unauthorized in PhotosController#create

401 Unauthorized ,怎么解决啊???

@zhangyi2099 是验证问题,你看看你的空间是否开启了允许外链

#13 楼 @stephen 允许外链、禁止外链都不行啊

@zhangyi2099 我是这个问题,或者你联系客服

#15 楼 @stephen 那应该是禁止外链,对吗?第一次搞这玩意,真心不懂

#16 樓 只需重寫 filename method

RestClient::Unauthorized

401 Unauthorized

请问有解决方法么

@zhangyi2099 @stephen 401 Unauthorized 问题解决,就是要加入 csrf token params!

params: {
                authenticity_token: "#{form_authenticity_token.to_s}"
             }

@cameo 这段代码,是直接添加到什么地方?

我的问题是在提交图片是出现如下错误。但是如果仅仅修改资料,不同时添加图片,提交更新是可以成功的。但是如果 add 头像就出现问题,这个是外链还是 gravatar 需要申请账号或者配置什么东西?

Processing by AccountController#update as HTML
  Parameters: {"utf8"=>"?", "authenticity_token"=>"[FILTERED]", "user"=>{"name"=>"林les", "avatar"=>#<ActionDispatch::Http::UploadedFile:0x000000076f89a0 @tempfile=#<Tempfile:/tmp/RackMultipart20140317-1459-1f99a9g>, @original_filename="caulin.jpg",, ........., "tagline"=>"Make your life a story worth telling", "bio"=>"目前}, "commit"=>"更新资料"}
Completed 500 Internal Server Error in 2036ms

RestClient::Unauthorized (401 Unauthorized):
  app/models/user.rb:211:in `update_with_password'
  app/controllers/account_controller.rb:10:in `update'

@zhangyi2099 @stephen 你们怎么解决的啦?给点思路吧,

谢谢各位

需要 登录 后方可回复, 如果你还没有账号请 注册新账号