samedi 21 août 2021

Getting error while displaying image "Can't resolve image into URL: undefined method `attachment_url' for #

Here's how my model looks like.

class Bug < ApplicationRecord
    has_many :bug_users, dependent: :destroy
    has_many :users , through: :bug_users  
    belongs_to :project
    has_one_attached :screenshot
end

The uploading part is working just fine but when i am displaying it in the view like this

<% @bugs.each do |bug| %>
<p>
   <strong>Title:</strong>
   <%= bug.title %>
</p>
<p>
<%if bug.screenshot.present? %>
   <strong>Screenshot:</strong>
   <%= image_tag bug.screenshot %>
<%end%>
</p>
<% end%>

I am getting the error




Aucun commentaire:

Enregistrer un commentaire