使用又拍云, 参考@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 谢谢,这个问题有遇到嘛?
RestClient::unauthorized in AccountsController#update
401 Unautorized
@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 你们怎么解决的啦?给点思路吧,
谢谢各位