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%>
Resolved! its kinda crazy actually i saw a tutorial in which he was generating the model like:
rails g model User avatar:attachment
So, I thought maybe i have to add a column in my model and when i did it gave:
# Could not dump table "bugs" because of following StandardError
# Unknown type 'attachment' for column 'screenshot'
in my schema.rb but it did resolve the error and then i again ran a migration to remove that column and surprisingly it was still not giving this error.