Search code examples
ruby-on-railsargument-error

ArgumentError in Posts#index after upgrading Rails


Everything was working fine until i switched from Rails 5.1.6 to 5.2.0. Now i'm getting this error when trying to load post images using the link_thumbnailer gem on the index page.

 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>

Solution

  • you should use LinkThumbnailer.generate(post.url).images.first.src.to_s instead of LinkThumbnailer.generate(post.url).images.first