can you fix this scope withattachments, i think its not working proprerly class…
- User
can you fix this scope with_attachments, i think its not working proprerly class SyncEvent < ApplicationRecord belongs_to :source has_one_attached :file has_one_attached :json
scope :with_logs, -> { where.not(log: nil) } scope :without_logs, -> { where(log: nil) } scope :with_attachments, -> { where.not(file_attachment: nil, json_attachment: nil) } scope :latest_with_attachments, -> { with_attachments.order(created_at: :desc).first }
Assistant
It looks like the
with_attachmentsscope is trying to findSyncEventrecords where both thefile_attachmentandjson_attachmentare not null. However, the proper way to check for the presence of an attached file in Active Storage is to use the#attached?method.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.