rails_blob_path host: 和only_path: true returns 一样吗?
rails_blob_path host: and only_path: true returns the same?
我正在想办法使用 Rails.application.routes.url_helpers.rails_blob_path
我有一个 class 和
has_one_attached :logo
然后我做
Rails.application.routes.url_helpers.rails_blob_path(record.logo)
它给我一个错误
Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true (ArgumentError)
好的,我试试
Rails.application.routes.url_helpers.rails_blob_path(obi.logo, host: "wwww.example.com" )
=> "/rails/active_storage/blobs/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBEUT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--5d977f0c66fecd8c8474355813aad9490fcdfbf2/picture.png"
结果与
相同
Rails.application.routes.url_helpers.rails_blob_path(obi.logo, only_path: true )
=> "/rails/active_storage/blobs/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBEUT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--5d977f0c66fecd8c8474355813aad9490fcdfbf2/picture.png"
当使用 host:
参数时,我希望它将“www.example.com”附加到输出。为什么结果与 only_path: true
相同?
When using the host: parameter I would expect it to attach "www.example.com" to the output. Why is it the same outcome as only_path: true ?
在Rails中有两种URL-helpers——path
和url
带后缀_path
-- 相对URL路径
带后缀_url
-- 绝对URL
Rails.application.routes.url_helpers.rails_blob_url(obi.logo, host: "https://www.example.com")
# => "https://www.example.com/rails/active_storage/blobs/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBEUT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--5d977f0c66fecd8c8474355813aad9490fcdfbf2/picture.png"
我正在想办法使用 Rails.application.routes.url_helpers.rails_blob_path
我有一个 class 和
has_one_attached :logo
然后我做
Rails.application.routes.url_helpers.rails_blob_path(record.logo)
它给我一个错误
Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true (ArgumentError)
好的,我试试
Rails.application.routes.url_helpers.rails_blob_path(obi.logo, host: "wwww.example.com" )
=> "/rails/active_storage/blobs/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBEUT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--5d977f0c66fecd8c8474355813aad9490fcdfbf2/picture.png"
结果与
相同Rails.application.routes.url_helpers.rails_blob_path(obi.logo, only_path: true )
=> "/rails/active_storage/blobs/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBEUT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--5d977f0c66fecd8c8474355813aad9490fcdfbf2/picture.png"
当使用 host:
参数时,我希望它将“www.example.com”附加到输出。为什么结果与 only_path: true
相同?
When using the host: parameter I would expect it to attach "www.example.com" to the output. Why is it the same outcome as only_path: true ?
在Rails中有两种URL-helpers——path
和url
带后缀_path
-- 相对URL路径
带后缀_url
-- 绝对URL
Rails.application.routes.url_helpers.rails_blob_url(obi.logo, host: "https://www.example.com")
# => "https://www.example.com/rails/active_storage/blobs/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBEUT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--5d977f0c66fecd8c8474355813aad9490fcdfbf2/picture.png"