Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/64.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 使用http基本身份验证通过回形针从URL保存图像_Ruby On Rails_Paperclip - Fatal编程技术网

Ruby on rails 使用http基本身份验证通过回形针从URL保存图像

Ruby on rails 使用http基本身份验证通过回形针从URL保存图像,ruby-on-rails,paperclip,Ruby On Rails,Paperclip,如何从使用http基本身份验证、使用曲别针进行身份验证的URL保存图像 我认为解决方案是这样的: require "open-uri" class User < ActiveRecord::Base has_attached_file :picture def picture_from_url(url) self.picture = open(url) end end 需要“打开uri” 类用户

如何从使用http基本身份验证、使用曲别针进行身份验证的URL保存图像

我认为解决方案是这样的:

require "open-uri"

class User < ActiveRecord::Base
  has_attached_file :picture

  def picture_from_url(url)
    self.picture = open(url)
  end
end
需要“打开uri”
类用户
但是我需要把证件放进去。我怎样才能解决这个问题


谢谢

我解决了链接的问题

需要“打开uri”
类用户
而且成功了

require "open-uri"

class User < ActiveRecord::Base
  has_attached_file :picture

  def picture_from_url(url)
    self.picture = open(url, http_basic_authentication: ['user', 'password'])
  end
end