gpt4 book ai didi

ruby-on-rails - ActionController::Base.helpers.image_url 不在初始化程序中生成散列版本

转载 作者:行者123 更新时间:2023-12-04 06:09:04 24 4
gpt4 key购买 nike

我在 config/initializers 中得到了一个包含以下内容的 constants.rb 文件:

DEFAULT_IMAGES  = {
profile: ActionController::Base.helpers.image_url('v2/default_profilepic.jpg'),
banner: ActionController::Base.helpers.image_url('v2/profile-banner.jpg'),
missing: ActionController::Base.helpers.image_url('v2/missing.png'),
}

当我尝试在代码中或什至在控制台中的某处调用 DEFAULT_IMAGES 时,我得到了没有哈希的图像。这是它应该做的吗?我的期望有误吗?

DEFAULT_IMAGES=> {:profile=>"http://localhost:3000/assets/v2/default_profilepic.jpg ", :banner=>"http://localhost:3000/assets/v2/profile-banner.jpg ", :missing=>"http://localhost:3000/assets/v2/missing.png "}

我希望这样的东西“/assets/v2/missing-d38d4bdbf9f2cf313e346a844de298c0.png”

最佳答案

你也可以试试 Proc

proc { ActionController::Base.helpers.image_path('v2/missing.png') }.call

关于ruby-on-rails - ActionController::Base.helpers.image_url 不在初始化程序中生成散列版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30545613/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com