显示图像时出错 "Can't resolve image into URL: undefined method `attachment_url' for #<ActionView::Base:0x0000000000b770>"

Getting error while displaying image "Can't resolve image into URL: undefined method `attachment_url' for #<ActionView::Base:0x0000000000b770>"

这是我的模型的样子。

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

上传部分工作正常,但是当我在视图中显示它时像这样

<% @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

已解决!这有点疯狂实际上我看到了一个他正在生成模型的教程:

rails g model User avatar:attachment

所以,我想也许我必须在我的模型中添加一列,当我这样做时给出了:

# Could not dump table "bugs" because of following StandardError 
# Unknown type 'attachment' for column 'screenshot'

在我的 schema.rb 但它确实解决了错误,然后我再次 运行 迁移以删除该列,令人惊讶的是它仍然没有给出这个错误。