我面临着链轮与倾斜宝石的奇怪错误.基本上,我加载图像的ERB模板(生成与倾斜)与图像标签,但当模板呈现时,它显示了 Sprockets::Rails::Helper:: AssetNotFound
. The asset "button.jpg" is not present in the asset pipeline.
. 我已经配置好了我的资产路径,下面我将附上文件。另一件事是,当我按下后退按钮并刷新页面时,图像会被加载适当的资产。我已经尝试了改变资产路径,以及尝试了 rake assets:precompile
但仍然保持不变。所有的资产都位于。app/assets/images
merge. rb
class Generator
include ApplicationHelper
include ActionView::Helpers::AssetTagHelper
include Sprockets::Rails::Helper
def initialize(template, scope = {})
scope.each do |k, v|
instance_variable_set k, v
end
f = "#{Rails.root}/app/views/#{template}.html.erb" if File.exist? "#{Rails.root}/app/views/#{template}.html.erb"
if f
@template = Tilt::ERBTemplate.new(f)
else
f = "#{Rails.root}/app/views/#{template}" if File.exist? "#{Rails.root}/app/views/#{template}"
@template = Tilt.new(f)
end
end
def request
ActionDispatch::Request.new({})
end
def render
@template.render(self) ===> Here is the render error
end
end
模板.erb
<div class="facility-button">
<center><%= link_to image_tag("button.jpg" , style: "max-width: 100%;height: auto;") , "#{@email.url}" %></center>
</div>
开发.rb
Rails.application.config.assets.version = '1.0'
Rails.application.config.assets.precompile += %w[vendor.js]
开发.rb
config.assets.compile = true
config.assets.debug = true
config.assets.quiet = true
如果有什么不清楚的地方,请写下注释。先谢谢你
通过添加这个,我的问题就解决了。
<center><%= link_to image_tag(ActionController::Base.helpers.asset_path("button.jpg") , style: "max-width: 100%;height: auto;") , "#{@email.url}" %></center>
如果有谁能详细说明为什么会这样,谢谢