0
的Rails 5.1.1, 紅寶石2.2.5p319, Carrierwave 1.1.0Carrierwave asset_path成爲導軌輔助使用時未定義的方法
試圖重構的是,得到重用所有懸停在應用到輔助的圖片我正在撞牆。問題模型中有兩個載波上傳器:Image和Imageback。我傳遞變量的方法,以確定我試圖打
Helper方法(如下面的代碼graphic
通過)(在application_helper.rb
)的列:
def issue_image_display(issue, graphic, size, sizeinpx, lodge = nil)
if graphic
if graphic == "imageback"
link_to image_tag(issue.imageback_url(size)),
imageback_url(:full), rel: :lazybox
else
link_to image_tag(issue.image_url(size)),
image_url(:full), rel: :lazybox
end
else
image_tag(
"missing_flap.jpg",
alt: "No Flap Image for #{issue.combined}",
style: "width: #{sizeinpx}px"
)
end
end
這是通過調用以下:
<ul class="issue-list" id="issues">
<div class="page">
<%# cache issue do %>
<%= render partial: "issues/issue_small",
collection: @issues,
as: :issue,
wishlist: false,
locals: {
size: :list,
sizeinpx: '200'
} %>
<%# end %>
</div>
</ul>
並且局部被遍歷,調用實際的輔助方法:
<li class="issue-container">
<article class="issue">
<%= issue_image_display(issue, issue.image, size, sizeinpx) %>
<p class="lodge-name">
<%= link_to issue.combined, lodge_issue_path(issue.lodge, issue) %>
<span><%= issue.first_issue.stamp("1969") if issue.first_issue %> | (OA BBv6: <%= issue.oa_bb_combined %>)</span>
</p>
<% if :wishlist == true -%>
<p class="add-to-wishlist">
<%= link_to 'Add to Wishlist', wishlist_items_path(issue_id: issue.id), method: :post, class: "button button-small" %>
</p>
<% end -%>
</article>
</li>
錯誤是:
ActionView::Template::Error at /issues
undefined method `asset_path' for #<ImageUploader::Uploader70194310458580:0x007faec5409400>
你在哪一行代碼中得到那個錯誤? – Pavan
它調用它作爲文件的第16行調用部分,當包括我修剪的其他東西是:'<%= render partial:「issues/issue_small」,' –