在Rails 5.1中,如果我们对公用文件夹中的文件使用asset_path,则会出现弃用警告.
DEPRECATION WARNING: The asset "favicon.ico" is not present in the asset pipeline.Falling back to an asset that may be in the public folder.
This behavior is deprecated and will be removed.
所以我试过了public_asset_path,但它不起作用,有帮手吗?
当我使用 Active Storage 时,当有人上传 .webp 图像时,当我运行file.attach(io: webp_file, filename: 'file.webp')它时,它会工作,然后 ActiveStorage 会自动运行一个作业ActiveStorage::AnalyzeJob
但这项工作提出:
MiniMagick::Error (`identify -format %[orientation] /tmp/ActiveStorage-114989-20180905-4-wak8ob.webp[0]` failed with error:
identify-im6.q16: delegate failed `'dwebp' -pam '%i' -o '%o'' @ error/delegate.c/InvokeDelegate/1919.
identify-im6.q16: unable to open file `/tmp/magick-1400SWBHj-p67HrV': No such file or directory @ error/constitute.c/ReadImage/544.
Run Code Online (Sandbox Code Playgroud)
虽然我在 Heroku-18 上,所以有一个名为“libwepb6”的库(https://devcenter.heroku.com/articles/stack-packages)
我必须创建一个 Heroku 构建包吗?
我在production.rb中使用它:
config.public_file_server.headers = {
'Cache-Control' => 'public, s-maxage=31536000, maxage=31536000',
'Expires' => "#{1.year.from_now.to_formatted_s(:rfc822)}"
}
Run Code Online (Sandbox Code Playgroud)
我通过cdn.mydomain.com,这是从www.mydomain.com阅读使用公共文件,并从www.mydomain.com它复制缓存控制,我设置与public_file_server.headers.
问题是我希望/ public中的某些文件没有那些缓存控制,例如我的service-worker.js
有没有办法只为/ public中的一个文件夹设置这些缓存控制?
另一个解决办法是删除此public_file_server.headers配置,并设置在CDN水平(我用cdn.mydomain.com/publicfile)高速缓存控制,并保持www.mydomain.com/serviceworker无缓存控制,为服务工人.
但也许有机会在Rails级别配置它?
在Rails 5.2中,Active Storage使我们能够生成永久性URL,这些URL通过每次调用时唯一的签名URL重定向到资产。
的HTML:
<img src='/rails/active_storage/blobs/ey...' />
服务器:
Started GET "/rails/active_storage/blobs/eyJfcmFpbH...
302 Redirected to https://bucket.amazon/image.jpg?X-Amz-Algorithm=AWS4-HMA...
Run Code Online (Sandbox Code Playgroud)
我想知道Active Storage正在向整体中添加HTTP请求的数量,网页中的一个blob_url =向整体中的另一个请求,以便通过302重定向获取最终的资产url。因此一页包含20张图像=> 20个附加请求。(但它们很快)
所以我的问题是:为什么使用此系统而不是直接使用最终URL(.service_url):
<img src='https://bucket.amazon/image.jpg?X-Amz-Algo...'> ?
我在想这些论点:(但是还有其他吗?)
ruby-on-rails http cache-control http-headers rails-activestorage
如何重写 Rails 中的方法?
更具体地说,我在 6.0.0.rc1 上,我想要这个提交,但它仅在 6.1 上可用: https: //github.com/rails/rails/pull/36072/files
我想重写私有def read_image方法
module ActiveStorage
class Analyzer::ImageAnalyzer < Analyzer
private
def read_image
Run Code Online (Sandbox Code Playgroud)
你会怎么做,在哪个 Rails 文件夹中?
如何使我在 Trix (ActionText) 编辑器中添加的链接在新窗口中使用 target="_blank" 打开链接?
class Post < ApplicationRecord
has_rich_text :rich_text_content
end
Run Code Online (Sandbox Code Playgroud) 我想为通过Active Storage上传到S3的文件设置缓存控件。
在rails repo中有这条线(链接在这里):
object_for(key).put(body: io, content_md5: checksum, content_type: content_type, **upload_options)
Run Code Online (Sandbox Code Playgroud)
所以我知道,如果:cache_control在** upload_options中有密钥,它就可以工作。(在此处链接到aws参考)
如何正确设置upload_options中的内容?
调用Turbolinks.visit时有一个进度条.
我想手动显示和隐藏它(因为我的一些xhr请求有点长),是否可能?
(在Turbolinks 3中,有Turbolinks.ProgressBar.start();但它不是公共API,不再工作了)
ruby ×2
actiontext ×1
actionview ×1
amazon-s3 ×1
heroku ×1
http ×1
http-headers ×1
overriding ×1
spring ×1
stimulusjs ×1
trix ×1
turbolinks ×1
webp ×1