【问题标题】:problem with <img image_path> vs <image_tag> with cloudinary<img image_path> 与 <image_tag> 与 cloudinary 的问题
【发布时间】:2019-09-13 13:40:13
【问题描述】:

我希望像这样在 rails 5.2 中使用 Image_tag:

<%= image_tag(@character.picture) %>

我收到以下错误:

"Can't resolve image into URL: undefined method `to_model' for #<PictureUploader:0x00007f619c7fd000>"

我已经成功使用了

 <img src="<%= image_path(@character.picture) %>">

我不确定为什么这两段代码会产生不同的结果。我是否缺少 image_tag 的一些质量?我可以轻松减少损失并使用 image_path 选项,但从美学上讲,我宁愿在我的代码中没有比所需更多的 html,并希望知道为什么这两位代码存在差异。

【问题讨论】:

    标签: ruby-on-rails cloudinary


    【解决方案1】:

    试试这个.......

    <%= image_tag(@character.picture.url) %>
    

    希望这会对你有所帮助。

    【讨论】:

      猜你喜欢
      • 2022-01-14
      • 2021-02-12
      • 1970-01-01
      • 2014-08-28
      • 2014-04-11
      • 2019-04-20
      • 1970-01-01
      • 2016-03-28
      • 1970-01-01
      相关资源
      最近更新 更多