我正在从Carrierwave 1.3.X迁移到2.2.X,我在这里和那里遇到了麻烦。我失败的一个片段是这样的:
def files
signable_template.signable_documents.map do |sd|
sd.document.cache_stored_file!
sd.document.file.to_file
end
end
字符串
上面的方法应该返回一个文件数组。相反,它会失败,并显示以下堆栈跟踪:
2023-07-04 23:12:24.058569 F [57069:puma threadpool 001 thread_local_var.rb:93] Rails -- Exception: NoMethodError: undefined method `to_file' for #<CarrierWave::Storage::Fog::File:0x00000001601b54c0 @uploader=#<SignableDocumentDocumentUploader:0x000000014ffdc1e0 @model=#<SignableDocument id: 1064252880, signable_template_id: 1064252880, account_id: 511176957, document: "offer.docx", preview: "preview.pdf", kind: "offer", created_at: "2023-07-04 09:06:30.424573000 +0000", updated_at: "2023-07-04 09:06:54.011485000 +0000">, @mounted_as=:document, @staged=true, @file=#<CarrierWave::Storage::Fog::File:0x00000001601b54c0 ...>, @filename="offer.docx", @cache_id="1688501542-652153691939222-0003-6859", @identifier="offer.docx", @versions={}, @versions_to_cache=nil, @versions_to_store=nil, @storage=#<CarrierWave::Storage::Fog:0x000000014dd1fe18 @uploader=#<SignableDocumentDocumentUploader:0x000000014ffdc1e0 ...>, @connection=#<Fog::AWS::Storage::Real:205320 @use_iam_profile=nil @instrumentor=nil @instrumentor_name="fog.aws.storage" @connection_options={:retry_limit=>5, :retry_interval=>1, :debug_response=>true, :headers=>{"User-Agent"=>"fog-core/2.3.0"}, :persistent=>false} @persistent=false @acceleration=false @signature_version=4 @enable_signature_v4_streaming=true @path_style=false @max_put_chunk_size=5368709120 @max_copy_chunk_size=5368709120 @disable_content_md5_validation=false @region="us-east-1" @endpoint=nil @host="s3.amazonaws.com" @scheme="https" @port=443 @aws_credentials_refresh_threshold_seconds=nil @aws_access_key_id="XXXXXXXXXXXXX" @aws_session_token=nil @aws_credentials_expire_at=nil @signer=#<Fog::AWS::SignatureV4:0x0000000149cb4108 @region="us-east-1", @service="s3", @aws_access_key_id="XXXXXXXXXXXXX", @hmac=#<Fog::HMAC:0x000000014cc978c0 @key="YYYYYYYYYYYYY", @digest=#<OpenSSL::Digest: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855>, @signer=#<Proc:0x000000014cc97488 /Users/markosfragkakis/.rvm/gems/ruby-3.2.2/gems/fog-core-2.3.0/lib/fog/core/hmac.rb:28 (lambda)>>> @connection=#<Fog::XML::Connection:0x000000014ddf6940 @path_prefix=nil, @excon=#<Excon::Connection:689e8 @pid=57069 @data={:chunk_size=>1048576, :ciphers=>"ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:DES-CBC3-SHA:!DSS", :connect_timeout=>60, :debug_request=>false, :debug_response=>true, :headers=>{"User-Agent"=>"fog-core/2.3.0"}, :idempotent=>false, :instrumentor_name=>"excon", :middlewares=>[Excon::Middleware::ResponseParser, Excon::Middleware::Expects, Excon::Middleware::Idempotent, Excon::Middleware::Instrumentor, Excon::Middleware::Mock], :mock=>false, :nonblock=>true, :omit_default_port=>false, :persistent=>false, :read_timeout=>60, :retry_errors=>[Excon::Error::Timeout, Excon::Error::Socket, Excon::Error::HTTPStatus], :retry_limit=>5, :ssl_verify_peer=>true, :ssl_uri_schemes=>["https"], :stubs=>:global, :tcp_nodelay=>false, :thread_safe_sockets=>true, :uri_parser=>URI, :versions=>"excon/0.99.0 (arm64-darwin21) ruby/3.2.2", :write_timeout=>60, :host=>"development-workable.s3.amazonaws.com", :hostname=>"development-workable.s3.amazonaws.com", :path=>"", :port=>443, :query=>nil, :scheme=>"https", :retry_interval=>1} @socket_key="https://development-workable.s3.amazonaws.com:443" @_excon_sockets={#<Thread:0x000000014f11b9d0 /Users/markosfragkakis/.rvm/gems/ruby-3.2.2/gems/logging-2.3.1/lib/logging/diagnostic_context.rb:471 sleep>=>{}} @persistent_socket_reusable=true @httplog_url="https://development-workable.s3.amazonaws.com:443">>>>, @original_filename="offer.docx", @cache_storage=#<CarrierWave::Storage::Fog:0x000000014ddf9dc0 @uploader=#<SignableDocumentDocumentUploader:0x000000014ffdc1e0 ...>, @connection=#<Fog::AWS::Storage::Real:205320 @use_iam_profile=nil @instrumentor=nil @instrumentor_name="fog.aws.storage" @connection_options={:retry_limit=>5, :retry_interval=>1, :debug_response=>true, :headers=>{"User-Agent"=>"fog-core/2.3.0"}, :persistent=>false} @persistent=false @acceleration=false @signature_version=4 @enable_signature_v4_streaming=true @path_style=false @max_put_chunk_size=5368709120 @max_copy_chunk_size=5368709120 @disable_content_md5_validation=false @region="us-east-1" @endpoint=nil @host="s3.amazonaws.com" @scheme="https" @port=443 @aws_credentials_refresh_threshold_seconds=nil @aws_access_key_id="XXXXXXXXXXXXX" @aws_session_token=nil @aws_credentials_expire_at=nil @signer=#<Fog::AWS::SignatureV4:0x0000000149cb4108 @region="us-east-1", @service="s3", @aws_access_key_id="XXXXXXXXXXXXX", @hmac=#<Fog::HMAC:0x000000014cc978c0 @key="YYYYYYYYYYYYY", @digest=#<OpenSSL::Digest: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855>, @signer=#<Proc:0x000000014cc97488 /Users/markosfragkakis/.rvm/gems/ruby-3.2.2/gems/fog-core-2.3.0/lib/fog/core/hmac.rb:28 (lambda)>>> @connection=#<Fog::XML::Connection:0x000000014ddf6940 @path_prefix=nil, @excon=#<Excon::Connection:689e8 @pid=57069 @data={:chunk_size=>1048576, :ciphers=>"ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:DES-CBC3-SHA:!DSS", :connect_timeout=>60, :debug_request=>false, :debug_response=>true, :headers=>{"User-Agent"=>"fog-core/2.3.0"}, :idempotent=>false, :instrumentor_name=>"excon", :middlewares=>[Excon::Middleware::ResponseParser, Excon::Middleware::Expects, Excon::Middleware::Idempotent, Excon::Middleware::Instrumentor, Excon::Middleware::Mock], :mock=>false, :nonblock=>true, :omit_default_port=>false, :persistent=>false, :read_timeout=>60, :retry_errors=>[Excon::Error::Timeout, Excon::Error::Socket, Excon::Error::HTTPStatus], :retry_limit=>5, :ssl_verify_peer=>true, :ssl_uri_schemes=>["https"], :stubs=>:global, :tcp_nodelay=>false, :thread_safe_sockets=>true, :uri_parser=>URI, :versions=>"excon/0.99.0 (arm64-darwin21) ruby/3.2.2", :write_timeout=>60, :host=>"development-workable.s3.amazonaws.com", :hostname=>"development-workable.s3.amazonaws.com", :path=>"", :port=>443, :query=>nil, :scheme=>"https", :retry_interval=>1} @socket_key="https://development-workable.s3.amazonaws.com:443" @_excon_sockets={#<Thread:0x000000014f11b9d0 /Users/markosfragkakis/.rvm/gems/ruby-3.2.2/gems/logging-2.3.1/lib/logging/diagnostic_context.rb:471 sleep>=>{}} @persistent_socket_reusable=true @httplog_url="https://development-workable.s3.amazonaws.com:443">>>>>, @base=#<CarrierWave::Storage::Fog:0x000000014ddf9dc0 @uploader=#<SignableDocumentDocumentUploader:0x000000014ffdc1e0 @model=#<SignableDocument id: 1064252880, signable_template_id: 1064252880, account_id: 511176957, document: "offer.docx", preview: "preview.pdf", kind: "offer", created_at: "2023-07-04 09:06:30.424573000 +0000", updated_at: "2023-07-04 09:06:54.011485000 +0000">, @mounted_as=:document, @staged=true, @file=#<CarrierWave::Storage::Fog::File:0x00000001601b54c0 ...>, @filename="offer.docx", @cache_id="1688501542-652153691939222-0003-6859", @identifier="offer.docx", @versions={}, @versions_to_cache=nil, @versions_to_store=nil, @storage=#<CarrierWave::Storage::Fog:0x000000014dd1fe18 @uploader=#<SignableDocumentDocumentUploader:0x000000014ffdc1e0 ...>, @connection=#<Fog::AWS::Storage::Real:205320 @use_iam_profile=nil @instrumentor=nil @instrumentor_name="fog.aws.storage" @connection_options={:retry_limit=>5, :retry_interval=>1, :debug_response=>true, :headers=>{"User-Agent"=>"fog-core/2.3.0"}, :persistent=>false} @persistent=false @acceleration=false @signature_version=4 @enable_signature_v4_streaming=true @path_style=false @max_put_chunk_size=5368709120 @max_copy_chunk_size=5368709120 @disable_content_md5_validation=false @region="us-east-1" @endpoint=nil @host="s3.amazonaws.com" @scheme="https" @port=443 @aws_credentials_refresh_threshold_seconds=nil @aws_access_key_id="XXXXXXXXXXXXX" @aws_session_token=nil @aws_credentials_expire_at=nil @signer=#<Fog::AWS::SignatureV4:0x0000000149cb4108 @region="us-east-1", @service="s3", @aws_access_key_id="XXXXXXXXXXXXX", @hmac=#<Fog::HMAC:0x000000014cc978c0 @key="YYYYYYYYYYYYY", @digest=#<OpenSSL::Digest: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855>, @signer=#<Proc:0x000000014cc97488 /Users/markosfragkakis/.rvm/gems/ruby-3.2.2/gems/fog-core-2.3.0/lib/fog/core/hmac.rb:28 (lambda)>>> @connection=#<Fog::XML::Connection:0x000000014ddf6940 @path_prefix=nil, @excon=#<Excon::Connection:689e8 @pid=57069 @data={:chunk_size=>1048576, :ciphers=>"ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:DES-CBC3-SHA:!DSS", :connect_timeout=>60, :debug_request=>false, :debug_response=>true, :headers=>{"User-Agent"=>"fog-core/2.3.0"}, :idempotent=>false, :instrumentor_name=>"excon", :middlewares=>[Excon::Middleware::ResponseParser, Excon::Middleware::Expects, Excon::Middleware::Idempotent, Excon::Middleware::Instrumentor, Excon::Middleware::Mock], :mock=>false, :nonblock=>true, :omit_default_port=>false, :persistent=>false, :read_timeout=>60, :retry_errors=>[Excon::Error::Timeout, Excon::Error::Socket, Excon::Error::HTTPStatus], :retry_limit=>5, :ssl_verify_peer=>true, :ssl_uri_schemes=>["https"], :stubs=>:global, :tcp_nodelay=>false, :thread_safe_sockets=>true, :uri_parser=>URI, :versions=>"excon/0.99.0 (arm64-darwin21) ruby/3.2.2", :write_timeout=>60, :host=>"development-workable.s3.amazonaws.com", :hostname=>"development-workable.s3.amazonaws.com", :path=>"", :port=>443, :query=>nil, :scheme=>"https", :retry_interval=>1} @socket_key="https://development-workable.s3.amazonaws.com:443" @_excon_sockets={#<Thread:0x000000014f11b9d0 /Users/markosfragkakis/.rvm/gems/ruby-3.2.2/gems/logging-2.3.1/lib/logging/diagnostic_context.rb:471 sleep>=>{}} @persistent_socket_reusable=true @httplog_url="https://development-workable.s3.amazonaws.com:443">>>>, @original_filename="offer.docx", @cache_storage=#<CarrierWave::Storage::Fog:0x000000014ddf9dc0 ...>>, @connection=#<Fog::AWS::Storage::Real:205320 @use_iam_profile=nil @instrumentor=nil @instrumentor_name="fog.aws.storage" @connection_options={:retry_limit=>5, :retry_interval=>1, :debug_response=>true, :headers=>{"User-Agent"=>"fog-core/2.3.0"}, :persistent=>false} @persistent=false @acceleration=false @signature_version=4 @enable_signature_v4_streaming=true @path_style=false @max_put_chunk_size=5368709120 @max_copy_chunk_size=5368709120 @disable_content_md5_validation=false @region="us-east-1" @endpoint=nil @host="s3.amazonaws.com" @scheme="https" @port=443 @aws_credentials_refresh_threshold_seconds=nil @aws_access_key_id="XXXXXXXXXXXXX" @aws_session_token=nil @aws_credentials_expire_at=nil @signer=#<Fog::AWS::SignatureV4:0x0000000149cb4108 @region="us-east-1", @service="s3", @aws_access_key_id="XXXXXXXXXXXXX", @hmac=#<Fog::HMAC:0x000000014cc978c0 @key="YYYYYYYYYYYYY", @digest=#<OpenSSL::Digest: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855>, @signer=#<Proc:0x000000014cc97488 /Users/markosfragkakis/.rvm/gems/ruby-3.2.2/gems/fog-core-2.3.0/lib/fog/core/hmac.rb:28 (lambda)>>> @connection=#<Fog::XML::Connection:0x000000014ddf6940 @path_prefix=nil, @excon=#<Excon::Connection:689e8 @pid=57069 @data={:chunk_size=>1048576, :ciphers=>"ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:DES-CBC3-SHA:!DSS", :connect_timeout=>60, :debug_request=>false, :debug_response=>true, :headers=>{"User-Agent"=>"fog-core/2.3.0"}, :idempotent=>false, :instrumentor_name=>"excon", :middlewares=>[Excon::Middleware::ResponseParser, Excon::Middleware::Expects, Excon::Middleware::Idempotent, Excon::Middleware::Instrumentor, Excon::Middleware::Mock], :mock=>false, :nonblock=>true, :omit_default_port=>false, :persistent=>false, :read_timeout=>60, :retry_errors=>[Excon::Error::Timeout, Excon::Error::Socket, Excon::Error::HTTPStatus], :retry_limit=>5, :ssl_verify_peer=>true, :ssl_uri_schemes=>["https"], :stubs=>:global, :tcp_nodelay=>false, :thread_safe_sockets=>true, :uri_parser=>URI, :versions=>"excon/0.99.0 (arm64-darwin21) ruby/3.2.2", :write_timeout=>60, :host=>"development-workable.s3.amazonaws.com", :hostname=>"development-workable.s3.amazonaws.com", :path=>"", :port=>443, :query=>nil, :scheme=>"https", :retry_interval=>1} @socket_key="https://development-workable.s3.amazonaws.com:443" @_excon_sockets={#<Thread:0x000000014f11b9d0 /Users/markosfragkakis/.rvm/gems/ruby-3.2.2/gems/logging-2.3.1/lib/logging/diagnostic_context.rb:471 sleep>=>{}} @persistent_socket_reusable=true @httplog_url="https://development-workable.s3.amazonaws.com:443">>>>, @path="/Users/markosfragkakis/dev/workable/tmp/uploads/1688501542-652153691939222-0003-6859/offer.docx", @content_type="application/vnd.openxmlformats-officedocument.wordprocessingml.document", @directory= <Fog::AWS::Storage::Directory
key="development-workable",
creation_date=nil
>, @file= <Fog::AWS::Storage::File
key="/Users/markosfragkakis/dev/workable/tmp/uploads/1688501542-652153691939222-0003-6859/offer.docx",
cache_control=nil,
content_disposition=nil,
content_encoding=nil,
content_length=7492,
content_md5=nil,
content_type="application/vnd.openxmlformats-officedocument.wordprocessingml.document",
etag="89e41846773950a5f9d87204e1c4f9e0",
expires=nil,
last_modified=nil,
metadata={"x-amz-id-2"=>"vvikP7WPUo1vhrkZ2ZPMbsc4fR4Sh3ylVltijYAjwi3Cx03wH0pew1k6Y4aJUcNci9KXoujfdns=", "x-amz-request-id"=>"QF7MP3YK0X5MF9EA"},
owner=nil,
storage_class=nil,
encryption="AES256",
encryption_key=nil,
version=nil,
kms_key_id=nil,
tags=nil,
website_redirect_location=nil
>>
/Users/markosfragkakis/dev/workable/app/services/offers/previewer.rb:27:in `block in files'
/Users/markosfragkakis/.rvm/gems/ruby-3.2.2/gems/activerecord-6.1.7.3/lib/active_record/relation/delegation.rb:88:in `each'
/Users/markosfragkakis/.rvm/gems/ruby-3.2.2/gems/activerecord-6.1.7.3/lib/active_record/relation/delegation.rb:88:in `each'
/Users/markosfragkakis/dev/workable/app/services/offers/previewer.rb:23:in `map'
/Users/markosfragkakis/dev/workable/app/services/offers/previewer.rb:23:in `files'
/Users/markosfragkakis/dev/workable/app/services/offers/previewer.rb:15:in `preview_token'
型
我试图理解为什么会发生这种情况,所以我设置了一个byebug断点并运行了一些片段:
[20, 29] in /Users/markosfragkakis/dev/workable/app/services/offers/previewer.rb
20: end
21:
22: def files
23: signable_template.signable_documents.map do |sd|
24: byebug
=> 25: sd.document.cache_stored_file!
26: sd.document.file.to_file
27: end
28: end
29:
(byebug) sd.document.cache_stored_file!
2023-07-04 23:42:34.253693 I [68127:puma threadpool 001] HttpLog -- [httplog] Connecting: development-workable.s3.amazonaws.com:443
2023-07-04 23:42:35.056167 I [68127:puma threadpool 001] HttpLog -- { :method => "HEAD",
...
# the file is downloaded successfully with status code 200
....
(byebug) sd.document.file.path
"/Users/markosfragkakis/dev/workable/tmp/uploads/1688503355-677970767411897-0001-8361/offer.docx"
# Looks correct, BUT this file doesn't exist in the filesystem!
(byebug) sd.document.file.to_file
*** NoMethodError Exception: undefined method `to_file' for #<CarrierWave::Storage::Fog::File:0x00000001211197a8 @uploader=#<SignableDocumentDocumentUploader:0x0000000123bb6420 @model=#<SignableDocument id: 1064252880, signable_template_id: 1064252880, account_id: 511176957, document: "offer.docx", preview: "preview.pdf", kind: "offer", created_at: "2023-07-04 09:06:30.424573000 +0000", updated_at: "2023-07-04 09:06:54.011485000 +0000">, @mounted_as=:document, @staged=true, @file=#<CarrierWave::Storage::Fog::File:0x00000001211197a8 ...>, @filename="offer.docx", @cache_id="1688503355-677970767411897-
...
...
...
型
在我的理解中,sd.document.file.path
的结果应该是该高速缓存中下载的文件的路径。虽然这看起来是一个合法的路径,但文件系统中实际上并不存在该文件。我猜这就是下面的错误的根本原因,undefined method
to_file ``。
你知道为什么这个代码不能在Carrierwave 2.2.X上工作吗?请注意,它适用于载波1.3.X。Carrierwave 3.0.0几天前发布,但它给出了相同的错误。
为了完成,这是相关的模型和上传器:
class SignableDocument < ApplicationRecord
mount_uploader :document, SignableDocumentDocumentUploader
...
end
class SignableDocumentDocumentUploader < CarrierWave::Uploader::Base
include UploaderWithFilenamesSanitizable
def self.fog_public
false
end
def store_dir
"uploads/signable_documents/#{model.account_id}/#{model.id}"
end
def extension_allowlist
%w[docx]
end
end
1条答案
按热度按时间ipakzgxi1#
#to_file
方法最近被添加到CarrierWave 3.x中。根据它的来源(和常识),你可以直接在代码中应用相同的逻辑:
字符串