升级Rails后Posts#index中的ArgumentError

时间:2019-05-31 10:52:50

标签: ruby-on-rails argument-error

一切正常,直到我从Rails 5.1.6切换到5.2.0。现在,当我尝试使用索引页面上的link_thumbnailer gem加载帖子图像时,出现此错误。

 ArgumentError in Posts#index Can't resolve image into URL: undefined method `to_model' for #<LinkThumbnailer::Models::Image:0x00007fd96d873ec8>
    Did you mean?  to_yaml 

  <div class="image"><%= link_to (image_tag LinkThumbnailer.generate(post.url).images.first, image_stats: false), post_path(post), class: "ui tiny circular centered image"  %></div>

1 个答案:

答案 0 :(得分:1)

您应该使用LinkThumbnailer.generate(post.url).images.first.src.to_s而不是LinkThumbnailer.generate(post.url).images.first