gpt4 book ai didi

ruby-on-rails - Carrierwave:无法将图像解析为 URL:未定义的方法 `to_model'

转载 作者:行者123 更新时间:2023-12-03 22:11:36 24 4
gpt4 key购买 nike

我收到此错误:

Can't resolve image into URL: undefined method `to_model' for #<PortfolioUploader:0x007fd1538a2a60>
Did you mean? to_xml

我正在使用carrierwave rails,当我检查我的表单时,如下所示:
  <% @portfolios.each do |portfolio_item| %>
<p><%= portfolio_item.title %> </p>
<p><%= image_tag portfolio_item.thumb_image unless portfolio_item.thumb_image.nil? %> </p>
<p><%= portfolio_item.body %> </p>
<p><%= link_to "Edit", edit_portfolio_path(portfolio_item) if logged_in?(:site_admin)%></p>
<p><%= link_to "Delete", portfolio_path(portfolio_item), method: :delete, data: { confirm: 'Are you sure?' } if logged_in?(:site_admin)%></p>
<% end %>

在我的表格上:
<%= render 'form', portfolio: @portfolio %>




<div class="field">
<%= f.file_field :main_image %>
</div>

<div class="field">
<%= f.file_field :thumb_image %>
</div>

在我的模型上,我放了 ff:
  mount_uploader :thumb_image, PortfolioUploader
mount_uploader :main_image, PortfolioUploader

知道我错过了什么吗?

最佳答案

我想应该是

<%= image_tag portfolio_item.thumb_image.url unless portfolio_item.thumb_image.nil? %>

关于ruby-on-rails - Carrierwave:无法将图像解析为 URL:未定义的方法 `to_model',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53883893/

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